Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.*;
- public class asd
- {
- static BufferedReader in=new BufferedReader(new InputStreamReader(System.in));
- public static void main(String args[])throws IOException
- {
- int x=0;
- int y=0;
- System.out.println("Choose a SHAPE");
- System.out.println("[1]Circle");
- System.out.println("[2]Triangle");
- System.out.println("[3]Square");
- x=Integer.parseInt(in.readLine());
- if ((x>=4)||(x
- {
- System.out.println("invalid option number");
- }
- else{
- if (x==1){
- System.out.println("Get C or A?");
- System.out.println("[1] C");
- System.out.println("[2] A");
- }
- if ((x==2)||(x==3)){
- System.out.println("Get A or P?");
- System.out.println("[1] A");
- System.out.println("[2] P");
- }
- System.out.println("enter the number of your choice:");
- y=Integer.parseInt(in.readLine());
- if ((y>=3)||(x
- {
- System.out.println("invalid option number");
- }
- else
- {
- cir(x,y);
- }
- }
- }
- public static void cir(int x,int y)throws IOException
- {
- double p=0;
- double b=0;
- double h=0;
- double q=0;
- if ((x==1)&&(y==1))
- {
- System.out.println("Enter Radius:");
- p=Double.parseDouble(in.readLine());
- p=2*3.1416*p;
- System.out.println("Circumference is: "+p);
- }
- if ((x==1)&&(y==2))
- {
- System.out.println("Enter Radius:");
- p=Double.parseDouble(in.readLine());
- p=3.1416*(p*p);
- System.out.println("Area is: "+p);
- }
- if ((x==2)&&(y==1))
- {
- System.out.println("Enter Base:");
- b=Double.parseDouble(in.readLine());
- System.out.println("Enter Height:");
- h=Double.parseDouble(in.readLine());
- p=(b*h)/2;
- System.out.println("Area is: "+p);
- }
- if ((x==2)&&(y==2))
- {
- System.out.println("Enter 1st side:");
- b=Double.parseDouble(in.readLine());
- System.out.println("Enter 2nd side:");
- h=Double.parseDouble(in.readLine());
- System.out.println("Enter 3rd side:");
- p=Double.parseDouble(in.readLine());
- p=b+h+p;
- System.out.println("Perimeter is: "+p);
- }
- if ((x==3)&&(y==1))
- {
- System.out.println("Enter 1st side");
- b=Double.parseDouble(in.readLine());
- System.out.println("Enter 2nd side:");
- h=Double.parseDouble(in.readLine());
- p=b*h;
- System.out.println("Area is: "+p);
- }
- if ((x==3)&&(y==2))
- {
- System.out.println("Enter 1st side:");
- b=Double.parseDouble(in.readLine());
- System.out.println("Enter 2nd side:");
- h=Double.parseDouble(in.readLine());
- p=(2*b)+(2*h);
- System.out.println("Perimeter is: "+p);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment