Advertisement
desislava_topuzakova

Untitled

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