Advertisement
Guest User

Untitled

a guest
Mar 19th, 2018
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.78 KB | None | 0 0
  1. package Lesson3;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class Figures {
  6. public static void main(String[] args) {
  7. Scanner scanner = new Scanner(System.in);
  8. String figure = scanner.nextLine();
  9. double a = Double.parseDouble(scanner.nextLine());
  10.  
  11. if (figure.equals("square")) {
  12. double area = a*a;
  13. System.out.println(area);
  14. } else if (figure.equals("rectangle")) {
  15. double b = Double.parseDouble(scanner.nextLine());
  16. double area = a*b;
  17. System.out.println(area);
  18. } else if (figure.equals("circle")) {
  19. double area = Math.PI*(a*a);
  20. System.out.println(area);
  21. } else if (figure.equals("triangle"));
  22. double b = Double.parseDouble(scanner.nextLine());
  23. double area = (a*b)/2;
  24. System.out.println(area);
  25.  
  26.  
  27.  
  28.  
  29. }
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement