Advertisement
veronikaaa86

07. Theatre Promotion

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