create a program to calculate and print the area of a rectangle if the users enters 1 and print the area of the square if the if the user enters 2
Answers
Answered by
2
import java.util.*;
class calculate
{
public static void main(String args[ ] )
{
Scanner sc = new Scanner(System.in);
System.out.println("Enter your choice 1 for rectangle or 2 for square);
int a = sc.nextInt();
switch(a)
{
case 1 :
System.out.println("Enter length and breadth of rectangle");
int len = sc.nextInt();
int brd = sc.nextInt();
int area = len*brd;
System.out.println("Area = " + area);
break;
case 2 :
System.out.println("Enter side measurement of square");
int side = sc.nextInt();
int ar = side * side ;
System.out.println("Area = " + ar);
break;
default :
System.out.println("Invalid choice entered");
}
}
}
program in java...
Answered by
1
Answer:
.com hhaklwwiomkskjjwowkkwkwo
Similar questions