Advertisement
DidiHristova93

Untitled

Jan 28th, 2019
91
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 hmm {
  4.  
  5. public static void main(String[] args) {
  6.  
  7. Scanner scanner = new Scanner(System.in);
  8.  
  9. String day = scanner.nextLine();
  10. int age = Integer.parseInt(scanner.nextLine());
  11.  
  12.  
  13. int price = 0;
  14.  
  15. if (day.equals("Weekday")) {
  16. if ((age >= 0 && age <= 18) || age > 64 && age <= 122) {
  17. price = 12;
  18. } else if (age > 18 && age <= 64) {
  19. price = 18;
  20. } else if (age < 0 || age > 123) {
  21. System.out.println("Error!");
  22.  
  23.  
  24. }
  25. } else if (day.equals("Weekend")) {
  26.  
  27. if ((age >= 0 && age <= 18) || age > 64 && age <= 122) {
  28. price = 15;
  29. } else if (age > 18 && age <= 64) {
  30. price = 20;
  31. } else if (age < 0 || age > 123) {
  32. System.out.println("Error!");
  33.  
  34.  
  35. }
  36. } else if (day.equals("Holiday")) {
  37.  
  38.  
  39. if (age >= 0 && age <= 18) {
  40. price = 5;
  41. } else if (age > 18 && age <= 64) {
  42. price = 12;
  43. } else if (age > 64 && age <= 122) {
  44. price = 10;
  45. } else if (age < 0 || age > 123) {
  46. System.out.println("Error!");
  47. return;
  48. }
  49. }
  50.  
  51. System.out.println(price +"$");
  52. }
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement