Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class App2 {
- public static void main(String[] args) {
- Scanner scan = new Scanner(System.in);
- System.out.println("Enter type on shape !");
- String shape = scan.next();
- if(shape.equals("square")){
- System.out.println("Enter side on square");
- double side = scan.nextDouble();
- double result = side * side;
- System.out.println("S = " + result);
- }else if(shape.equals("rectangle")){
- System.out.println("Enter side one on rectangle");
- double side1 = scan.nextDouble();
- System.out.println("Enter side two on rectangle");
- double side2 = scan.nextDouble();
- double result = side1 * side2;
- System.out.println(result);
- }else if(shape.equals("circle")){
- System.out.println("Enter radius ");
- double radius = scan.nextDouble();
- //double result = 3.14 * radius * radius;
- double result = Math.PI * radius * radius;
- System.out.printf("s = %.2f",result);
- System.out.println("s = " + result);
- }else if(shape.equals("triangle")){
- System.out.println("Enter a:");
- double a = scan.nextDouble();
- System.out.println("Enter b:");
- double b = scan.nextDouble();
- double r = (a * b) / 2;
- System.out.printf("%.2f",r);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement