-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathques5.java
35 lines (35 loc) · 1.08 KB
/
ques5.java
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
package ques;
import java.util.Scanner;
public class ques5
{
double pi = 3.14,perimeter;
Scanner s = new Scanner(System.in);
void circle()
{
System.out.println("Enter the radius of circle: ");
int radius = s.nextInt();
perimeter = 2 * pi * radius;
System.out.println("The perimeter of the circle: "+perimeter);
}
void rectangle()
{
System.out.println("Enter length of rectangle: ");
int length = s.nextInt();
System.out.println("Enter breadth of rectangle: ");
int breadth = s.nextInt();
perimeter = 2 * (length + breadth);
System.out.println("The perimeter of the rectangle: "+perimeter);
}
public static void main(String[] args) {
Scanner io = new Scanner(System.in);
System.out.println("Input the radius of the circle: ");
double radius = io.nextDouble();
System.out.println("Perimeter is = " + (2 * radius * Math.PI));
System.out.println("Area is = " + (Math.PI * radius * radius));
}
{
ques5 obj=new ques5();
obj.circle();
obj.rectangle();
}
}