stoyanoff

Shop

Jun 23rd, 2020
160
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 3.47 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Shop_05 {
  4.     public static void main(String[] args) {
  5.         Scanner myScan = new Scanner(System.in);
  6.  
  7.         String product = myScan.nextLine();
  8.         String town = myScan.nextLine();
  9.         double order = Double.parseDouble(myScan.nextLine());
  10.  
  11.         double totalPriceOrder = 0;
  12.  
  13.         // town check - Sofia Plovdiv Varna
  14.  
  15.         switch (town) {
  16.             case "Sofia":
  17.                 switch (product) {
  18.                     case "coffee":
  19.                         totalPriceOrder = order * 0.50;
  20.                         System.out.println(totalPriceOrder);
  21.                         break;
  22.                     case "water":
  23.                         totalPriceOrder = order * 0.80;
  24.                         System.out.println(totalPriceOrder);
  25.                         break;
  26.                     case "beer":
  27.                         totalPriceOrder = order * 1.20;
  28.                         System.out.println(totalPriceOrder);
  29.                         break;
  30.                     case "sweets":
  31.                         totalPriceOrder = order * 1.45;
  32.                         System.out.println(totalPriceOrder);
  33.                         break;
  34.                     case "peanuts":
  35.                         totalPriceOrder = order * 1.60;
  36.                         System.out.println(totalPriceOrder);
  37.                         break;
  38.                 }
  39.                 break;
  40.             case "Plovdiv":
  41.                 switch (product) {
  42.                     case "coffee":
  43.                         totalPriceOrder = order * 0.40;
  44.                         System.out.println(totalPriceOrder);
  45.                         break;
  46.                     case "water":
  47.                         totalPriceOrder = order * 0.70;
  48.                         System.out.println(totalPriceOrder);
  49.                         break;
  50.                     case "beer":
  51.                         totalPriceOrder = order * 1.15;
  52.                         System.out.println(totalPriceOrder);
  53.                         break;
  54.                     case "sweets":
  55.                         totalPriceOrder = order * 1.30;
  56.                         System.out.println(totalPriceOrder);
  57.                         break;
  58.                     case "peanuts":
  59.                         totalPriceOrder = order * 1.50;
  60.                         System.out.println(totalPriceOrder);
  61.                         break;
  62.                 }
  63.                 break;
  64.             case "Varna":
  65.                 switch (product) {
  66.                     case "coffee":
  67.                         totalPriceOrder = order * 0.45;
  68.                         System.out.println(totalPriceOrder);
  69.                         break;
  70.                     case "water":
  71.                         totalPriceOrder = order * 0.70;
  72.                         System.out.println(totalPriceOrder);
  73.                         break;
  74.                     case "beer":
  75.                         totalPriceOrder = order * 1.10;
  76.                         System.out.println(totalPriceOrder);
  77.                         break;
  78.                     case "sweets":
  79.                         totalPriceOrder = order * 1.35;
  80.                         System.out.println(totalPriceOrder);
  81.                         break;
  82.                     case "peanuts":
  83.                         totalPriceOrder = order * 1.55;
  84.                         System.out.println(totalPriceOrder);
  85.                         break;
  86.                 }
  87.                 break;
  88.  
  89.         }
  90.     }
  91. }
Add Comment
Please, Sign In to add comment