Advertisement
mitry99

Untitled

Sep 22nd, 2019
161
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.35 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Theatre {
  4. public static void main(String[] args) {
  5. Scanner scanner = new Scanner(System.in);
  6.  
  7. String day = scanner.nextLine().toLowerCase();
  8. int age = scanner.nextInt();
  9. double price = 0.0;
  10. boolean isValid = true;
  11.  
  12. if (day.equals("weekday")) {
  13. if (age >= 0 && age <= 18) {
  14. price = 12;
  15. } else if (age > 18 && age <= 64) {
  16. price = 18;
  17. } else if (age > 64 && age <= 122) {
  18. price = 12;
  19. }
  20. } else if (day.equals("weekend")) {
  21. if (age >= 0 && age <= 18) {
  22. price = 15;
  23. } else if (age > 18 && age <= 64) {
  24. price = 20;
  25. } else if (age > 64 && age <= 122) {
  26. price = 15;
  27. }
  28. } else if (day.equals("holiday")) {
  29. if (age >= 0 && age <= 18) {
  30. price = 5;
  31. } else if (age > 18 && age <= 64) {
  32. price = 12;
  33. } else if (age > 64 && age <= 122) {
  34. price = 10;
  35. }
  36. } else {
  37. isValid = false;
  38. }
  39.  
  40. if (isValid) {
  41. System.out.printf("%.0f$", price);
  42. } else {
  43. System.out.println("Error!");
  44. }
  45.  
  46.  
  47. }
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement