Giroe

Untitled

Feb 24th, 2020
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.00 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Main {
  4. public static void main(String[] args) {
  5. Scanner scanner = new Scanner(System.in);
  6. String type = scanner.nextLine();
  7.  
  8. float laturaPatrat=Float.parseFloat(scanner.nextLine());
  9. float razaCerc = Float.parseFloat(scanner.nextLine());
  10. float latimeDreptunghi = Float.parseFloat(scanner.nextLine());
  11. float lungimeDreptunghi = Float.parseFloat(scanner.nextLine());
  12. int ok=0;
  13. if(type.equals("square")) {
  14. System.out.printf("%.2f",laturaPatrat * laturaPatrat);
  15. ok=1;
  16. }
  17. else{
  18. if(type.equals("rectangle")) {
  19. System.out.printf("%.2f",latimeDreptunghi * lungimeDreptunghi);
  20. ok=1;
  21. }
  22. }
  23. if(type.equals("circle")) {
  24. System.out.printf("%.2f",Math.PI * razaCerc * razaCerc);
  25. ok = 1;
  26. }
  27. if(ok==0)
  28. System.out.println("Unknown figure");
  29. }
  30. }
Advertisement
Add Comment
Please, Sign In to add comment