Advertisement
SUni2020

Sushi Time

Mar 22nd, 2020
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.22 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Problem03 {
  4. public static void main(String[] args) {
  5. Scanner scanner = new Scanner(System.in);
  6. String sushiType = scanner.nextLine();
  7. String restaurant = scanner.nextLine();
  8. int portions = Integer.parseInt(scanner.nextLine());
  9. String online = scanner.nextLine();
  10. double total = 0;
  11. double price = 0;
  12.  
  13. switch (restaurant)
  14. {
  15. case "Sushi Zone":
  16. switch (sushiType)
  17. {
  18. case "sashimi":
  19. price = 4.99;
  20. break;
  21. case "maki":
  22. price = 5.29;
  23. break;
  24. case "uramaki":
  25. price = 5.99;
  26. break;
  27. case "temaki":
  28. price = 4.29;
  29. break;
  30. default:
  31. break;
  32. }
  33. break;
  34. case "Sushi Time":
  35. switch (sushiType)
  36. {
  37. case "sashimi":
  38. price = 5.49;
  39. break;
  40. case "maki":
  41. price = 4.69;
  42. break;
  43. case "uramaki":
  44. price = 4.49;
  45. break;
  46. case "temaki":
  47. price = 5.19;
  48. break;
  49. default:
  50. break;
  51. }
  52. break;
  53. case "Sushi Bar":
  54. switch (sushiType)
  55. {
  56. case "sashimi":
  57. price = 5.25;
  58. break;
  59. case "maki":
  60. price = 5.55;
  61. break;
  62. case "uramaki":
  63. price = 6.25;
  64. break;
  65. case "temaki":
  66. price = 4.75;
  67. break;
  68. default:
  69. break;
  70. }
  71. break;
  72. case "Asian Pub":
  73. switch (sushiType)
  74. {
  75. case "sashimi":
  76. price = 4.50;
  77. break;
  78. case "maki":
  79. price = 4.80;
  80. break;
  81. case "uramaki":
  82. price = 5.50;
  83. break;
  84. case "temaki":
  85. price = 5.50;
  86. break;
  87. default:
  88. break;
  89. }
  90. break;
  91. default:
  92. break;
  93. }
  94. // .equalsIgnoreCase(""Sushi Time"" ) || .equalsIgnoreCase("Sushi Bar" ) ||.equalsIgnoreCase("Asian Pub"" )
  95. // if ( (restaurant.equals("Sushi Zone" ) || (restaurant.equals( "Sushi Time" ) || (restaurant.equals( "Sushi Bar" ) || (restaurant.equals( "Asian Pub" )) {
  96.  
  97. if (sushiType.equals("sashimi"))
  98. {
  99. total = portions * price;
  100. }
  101. else if (sushiType.equals("maki"))
  102. {
  103. total = portions * price;
  104. }
  105. else if (sushiType.equals("uramaki"))
  106. {
  107. total = portions * price;
  108. }
  109. else if (sushiType.equals("temaki"))
  110. {
  111. total = portions * price;
  112. }
  113. if (online .equals("Y") )
  114. {
  115. total = total * 0.20 + total;
  116. }
  117. System.out.printf("Total price: %f lv.", total);
  118. }
  119. // if (restaurant != "Sushi Zone" && restaurant != "Sushi Time" &&
  120. // restaurant != "Sushi Bar" && restaurant != "Asian Pub") {
  121. // System.out.printf("%s is invalid restaurant!", restaurant);
  122.  
  123. }
  124. //else
  125. // {
  126. // System.out.printf("%s is invalid restaurant!", restaurant);
  127. // }
  128. //}
  129. //}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement