Advertisement
psi_mmobile

Untitled

Apr 22nd, 2022
1,054
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.63 KB | None | 0 0
  1. public class MyClass {
  2.     public static void main(String args[]) {
  3.         java.util.Scanner scanner = new java.util.Scanner(System.in);
  4.         String product = scanner.nextLine();
  5.         String city = scanner.nextLine();
  6.         double quantity = scanner.nextDouble();
  7.        
  8.         switch(product) {
  9.             case "coffee" :
  10.                 switch(city) {
  11.                     case "Varna" :
  12.                         System.out.print(0.45 * quantity);
  13.                         break;
  14.                     case "Sofia" :
  15.                         System.out.print(0.5 * quantity);
  16.                         break;
  17.                     case "Plovdiv" :
  18.                         System.out.print(0.4 * quantity);
  19.                         break;
  20.                 } break;
  21.             case "water" :
  22.                 switch(city) {
  23.                     case "Varna" :
  24.                         System.out.print(0.7 * quantity);
  25.                         break;
  26.                     case "Sofia" :
  27.                         System.out.print(0.8 * quantity);
  28.                         break;
  29.                     case "Plovdiv" :
  30.                         System.out.print(0.7 * quantity);
  31.                         break;
  32.                 } break;
  33.             case "beer" :
  34.                 switch(city) {
  35.                     case "Varna" :
  36.                         System.out.print(1.1 * quantity);
  37.                         break;
  38.                     case "Sofia" :
  39.                         System.out.print(1.2 * quantity);
  40.                         break;
  41.                     case "Plovdiv" :
  42.                         System.out.print(1.15 * quantity);
  43.                         break;
  44.                 } break;
  45.             case "sweets" :
  46.                 switch(city) {
  47.                     case "Varna" :
  48.                         System.out.print(1.35 * quantity);
  49.                         break;
  50.                     case "Sofia" :
  51.                         System.out.print(1.45 * quantity);
  52.                         break;
  53.                     case "Plovdiv" :
  54.                         System.out.print(1.3 * quantity);
  55.                         break;
  56.                 } break;
  57.             case "peanuts" :
  58.                 switch(city) {
  59.                     case "Varna" :
  60.                         System.out.print(1.55 * quantity);
  61.                         break;
  62.                     case "Sofia" :
  63.                         System.out.print(1.6 * quantity);
  64.                         break;
  65.                     case "Plovdiv" :
  66.                         System.out.print(1.5 * quantity);
  67.                         break;
  68.                 } break;
  69.         }
  70.     }
  71. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement