Advertisement
finderabc

SushiTime

Mar 9th, 2019
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 6.31 KB | None | 0 0
  1. import java.util.Scanner;
  2. /*Суши
  3. Суши е японско ястие, което напоследък набира огромна популярност
  4. както в Европа, така и в България. В таблицата са посочени основните видове
  5.  суши и ресторантите, които го предлагат, както и цената за порция суши.
  6.   Ако искате да си поръчате за вкъщи се доплаща цена за доставка, която е на
  7.   стойност 20 % от цялата поръчка.
  8. Видове /
  9. Ресторанти    Сашими
  10. (sashimi)   Маки
  11. (maki)  Урамаки
  12. (uramaki)   Темаки
  13. (temaki)
  14. Sushi Zone  4.99 лв.  5.29 лв.  5.99 лв.  4.29 лв.
  15. Sushi Time  5.49 лв.  4.69 лв.  4.49 лв.  5.19 лв.
  16. Sushi Bar   5.25 лв.  5.55 лв.  6.25 лв.  4.75 лв.
  17. Asian Pub   4.50 лв.  4.80 лв.  5.50 лв.  5.50 лв.
  18. Напишете програма, която изчислява колко ще е цената за поръчката.
  19. При въвеждане на невалиден ресторант да се отпечатва: {име на ресторанта}
  20. is invalid restaurant!
  21. Вход
  22. Входът се чете от конзолата и съдържа точно 4 реда:
  23. • Видът суши –  текст  –  една от възможностите: "sashimi", "maki", "uramaki", "temaki"
  24. • Име на ресторанта – текст – една от възможностите: "Sushi Zone", "Sushi Time",
  25. "Sushi Bar", "Asian Pub"
  26. • Брой порции – цяло число в интервала [1…100]
  27. • Поръчка – символ – 'Y' или 'N'
  28. Изход
  29. Да се отпечата на конзолата :
  30. • Total price: {крайна цена} lv.
  31. където резултатът трябва да бъде закръглен до по-голямото цяло число.
  32. */
  33. public class TestExamTask3_SushiTime {
  34.     public static void main(String[] args) {
  35.         Scanner scanner = new Scanner(System.in);
  36.  
  37.         String sushiType = scanner.nextLine();
  38.         String restaurantName = scanner.nextLine();
  39.         int portions = Integer.parseInt(scanner.nextLine());
  40.         String takeOutOrder = scanner.nextLine();
  41.         double sushiPrice = 0;
  42.  
  43.         switch (restaurantName) {
  44.             case "Sushi Zone":
  45.                 switch (sushiType) {
  46.                     case "sashimi":
  47.                         sushiPrice = portions * 4.99;
  48.                         break;
  49.                     case "maki":
  50.                         sushiPrice = portions * 5.29;
  51.                         break;
  52.                     case "uramaki":
  53.                         sushiPrice = portions * 5.99;
  54.                         break;
  55.                     case "temaki":
  56.                         sushiPrice = portions * 4.29;
  57.                         break;
  58.                 }
  59.                 if (takeOutOrder.equalsIgnoreCase("y")) {
  60.                     double totalPrice = Math.ceil(sushiPrice + (sushiPrice * 0.2));
  61.                     System.out.printf("Total price: %.0f lv.", totalPrice);
  62.                 } else {
  63.                     System.out.printf("Total price: %.0f lv.", Math.ceil(sushiPrice));
  64.                 }
  65.                 break;
  66.             case "Sushi Time":
  67.                 switch (sushiType) {
  68.                     case "sashimi":
  69.                         sushiPrice = portions * 5.49;
  70.                         break;
  71.                     case "maki":
  72.                         sushiPrice = portions * 4.69;
  73.                         break;
  74.                     case "uramaki":
  75.                         sushiPrice = portions * 4.49;
  76.                         break;
  77.                     case "temaki":
  78.                         sushiPrice = portions * 5.19;
  79.                         break;
  80.                 }
  81.                 if (takeOutOrder.equalsIgnoreCase("y")) {
  82.                     double totalPrice = Math.ceil(sushiPrice + (sushiPrice * 0.2));
  83.                     System.out.printf("Total price: %.0f lv.", totalPrice);
  84.                 } else {
  85.                     System.out.printf("Total price: %.0f lv.", Math.ceil(sushiPrice));
  86.                 }
  87.                 break;
  88.             case "Sushi Bar":
  89.                 switch (sushiType) {
  90.                     case "sashimi":
  91.                         sushiPrice = portions * 5.25;
  92.                         break;
  93.                     case "maki":
  94.                         sushiPrice = portions * 5.55;
  95.                         break;
  96.                     case "uramaki":
  97.                         sushiPrice = portions * 6.25;
  98.                         break;
  99.                     case "temaki":
  100.                         sushiPrice = portions * 4.75;
  101.                         break;
  102.  
  103.                 }
  104.                 if (takeOutOrder.equalsIgnoreCase("y")) {
  105.                     double totalPrice = Math.ceil(sushiPrice + (sushiPrice * 0.2));
  106.                     System.out.printf("Total price: %.0f lv.", totalPrice);
  107.                 } else {
  108.                     System.out.printf("Total price: %.0f lv.", Math.ceil(sushiPrice));
  109.                 }
  110.                 break;
  111.             case "Asian Pub":
  112.                 switch (sushiType) {
  113.                     case "sashimi":
  114.                         sushiPrice = portions * 4.50;
  115.                         break;
  116.                     case "maki":
  117.                         sushiPrice = portions * 4.80;
  118.                         break;
  119.                     case "uramaki":
  120.                         sushiPrice = portions * 5.50;
  121.                         break;
  122.                     case "temaki":
  123.                         sushiPrice = portions * 5.50;
  124.                         break;
  125.                 }
  126.                 if (takeOutOrder.equalsIgnoreCase("y")) {
  127.                     double totalPrice = Math.ceil(sushiPrice + (sushiPrice * 0.2));
  128.                     System.out.printf("Total price: %.0f lv.", totalPrice);
  129.                 } else {
  130.                     System.out.printf("Total price: %.0f lv.", Math.ceil(sushiPrice));
  131.                 }
  132.                 break;
  133.             default:
  134.                 System.out.printf("%s is invalid restaurant!", restaurantName);
  135.                 break;
  136.         }
  137.     }
  138. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement