Advertisement
desislava_topuzakova

04. Small Shop

May 2nd, 2020
799
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.81 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class SmallShop_04 {
  4.     public static void main(String[] args) {
  5.         Scanner scanner = new Scanner(System.in);
  6.  
  7.         String product = scanner.nextLine();
  8.         String town = scanner.nextLine();
  9.         double quantity = Double.parseDouble(scanner.nextLine());
  10.  
  11.         //Sofia, Plovdiv, Varna
  12.         switch (town) {
  13.             case "Sofia":
  14.                 switch (product) {
  15.                     case "coffee":
  16.                         System.out.println(quantity * 0.5);
  17.                         break;
  18.                     case "water":
  19.                         System.out.println(quantity * 0.80);
  20.                         break;
  21.                     case "beer":
  22.                         System.out.println(quantity * 1.20);
  23.                         break;
  24.                     case "sweets":
  25.                         System.out.println(quantity * 1.45);
  26.                         break;
  27.                     case "peanuts":
  28.                         System.out.println(quantity * 1.60);
  29.                         break;
  30.                 }
  31.                 //какво правим ако сме в София
  32.                 break;
  33.             case "Plovdiv":
  34.                 switch (product) {
  35.                     case "coffee":
  36.                         System.out.println(quantity * 0.4);
  37.                         break;
  38.                     case "water":
  39.                         System.out.println(quantity * 0.70);
  40.                         break;
  41.                     case "beer":
  42.                         System.out.println(quantity * 1.15);
  43.                         break;
  44.                     case "sweets":
  45.                         System.out.println(quantity * 1.30);
  46.                         break;
  47.                     case "peanuts":
  48.                         System.out.println(quantity * 1.50);
  49.                         break;
  50.                 }
  51.                 //какво правим ако сме в Пловдив
  52.                 break;
  53.             case "Varna":
  54.                 //какво правим ако сме във Варна
  55.                 switch (product) {
  56.                     case "coffee":
  57.                         System.out.println(quantity * 0.45);
  58.                         break;
  59.                     case "water":
  60.                         System.out.println(quantity * 0.70);
  61.                         break;
  62.                     case "beer":
  63.                         System.out.println(quantity * 1.10);
  64.                         break;
  65.                     case "sweets":
  66.                         System.out.println(quantity * 1.35);
  67.                         break;
  68.                     case "peanuts":
  69.                         System.out.println(quantity * 1.55);
  70.                         break;
  71.                 }
  72.                 break;
  73.  
  74.         }
  75.     }
  76. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement