GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Java/AreaInterface.java at main · Gokulkrishnajayan/Java

Expand file tree

/

AreaInterface.java

Copy path
More file actions
More file actions

Latest commit

 

History

History
History
133 lines (121 loc) · 2.86 KB
/

AreaInterface.java

Copy path

File metadata and controls

133 lines (121 loc) · 2.86 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
import java.util.*;
interface shape{
public void getter();
public void area();
public void perimeter();
}
class circle implements shape{
double r,a,p;
public void getter(){
Scanner sc=new Scanner(System.in);
System.out.print("Enter the radius of the circle:");
r = sc.nextInt();
}
public void area(){
a = 3.14*r*r;
System.out.println("Area of circle is "+a);
}
public void perimeter(){
p= 2*3.14*r;
System.out.println("Perimeter of circle is "+p);
}
}
class square implements shape{
double l,a,p;
public void getter(){
Scanner sc=new Scanner(System.in);
System.out.print("Enter the lenght of the square:");
l=sc.nextInt();
}
public void area(){
a=l*l;
System.out.println("Area of square is "+a);
}
public void perimeter(){
p=l*4;
System.out.println("Perimeter of square is "+p);
}
}
class triangle implements shape{
double a,b,c,d,h,p;
Scanner sc=new Scanner(System.in);
public void getter(){
System.out.print("Enter the base of triangle:");
b=sc.nextDouble();
System.out.print("Enter the height of triangle:");
h=sc.nextDouble();
System.out.print("Enter the first side of triangle:");
d=sc.nextDouble();
System.out.print("Enter the second side of triangle:");
c=sc.nextDouble();
}
public void area(){
a=0.5*b*h;
System.out.println("Area of triangle is "+a);
}
public void perimeter(){
p=a+b+c;
System.out.println("Perimeter of triangle is "+p);
}
}
class rectangle implements shape{
int l,a,b,p;
public void getter(){
Scanner sc=new Scanner(System.in);
System.out.print("Enter the lenght of the rectangle:");
l = sc.nextInt();
System.out.print("Enter the breadth of the rectangle:");
b = sc.nextInt();
}
public void area(){
a = l*b;
System.out.println("Area of rectangle is "+a);
}
public void perimeter(){
p = (l+b)*2;
System.out.println("Perimeter of rectangle is "+p);
}
}
public class AreaInterface{
public static void main(String args[]){
int ch,wish;
circle cri=new circle();
square sqr=new square();
triangle tri=new triangle();
rectangle rec=new rectangle();
Scanner sc =new Scanner(System.in);
do
{
System.out.println("Menu\n1.Circle\n2.Square\n3.Triangle\n4.Rectangle");
System.out.print("Enter your choice:");
ch=sc.nextInt();
switch(ch){
case 1:
cri.getter();
cri.area();
cri.perimeter();
break;
case 2:
sqr.getter();
sqr.area();
sqr.perimeter();
break;
case 3:
tri.getter();
tri.area();
tri.perimeter();
break;
case 4:
rec.getter();
rec.area();
rec.perimeter();
break;
default:
System.out.println("Invalid choice");
break;
}
System.out.print("Do you wish to continue(1/0):?");
wish=sc.nextInt();
}while(wish==1);
}
}
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.