deyanivanov966

05. Small Shop

Aug 23rd, 2020 (edited)
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.12 KB | None | 0 0
  1. import com.sun.jdi.DoubleValue;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class SmallShop {
  6.     public static void main(String[] args) {
  7.         Scanner scanner = new Scanner(System.in);
  8.  
  9.         double price = 0;
  10.         String product = scanner.nextLine();
  11.         String city = scanner.nextLine();
  12.         double totalProduct = Double.parseDouble(scanner.nextLine());
  13.  
  14.         if (product.equals("coffee") && city.equals("Sofia")) {
  15.             price = totalProduct * 0.5;
  16.         } else if (product.equals("coffee") && city.equals("Plovdiv")) {
  17.             price = totalProduct * 0.4;
  18.         } else if (product.equals("coffee") && city.equals("Varna")) {
  19.             price = totalProduct * 0.45;
  20.         }
  21.  
  22.         if (product.equals("water") && city.equals("Sofia")) {
  23.             price = totalProduct * 0.8;
  24.         } else if (product.equals("water") && city.equals("Plovdiv")) {
  25.             price = totalProduct * 0.7;
  26.         } else if (product.equals("water") && city.equals("Varna")) {
  27.             price = totalProduct * 0.7;
  28.         }
  29.  
  30.         if (product.equals("beer") && city.equals("Sofia")) {
  31.             price = totalProduct * 1.2;
  32.         } else if (product.equals("beer") && city.equals("Plovdiv")) {
  33.             price = totalProduct * 1.15;
  34.         } else if (product.equals("beer") && city.equals("Varna")) {
  35.             price = totalProduct * 1.1;
  36.         }
  37.  
  38.         if (product.equals("sweets") && city.equals("Sofia")) {
  39.             price = totalProduct * 1.45;
  40.         } else if (product.equals("sweets") && city.equals("Plovdiv")) {
  41.             price = totalProduct * 1.3;
  42.         } else if (product.equals("sweets") && city.equals("Varna")) {
  43.             price = totalProduct * 1.35;
  44.         }
  45.  
  46.         if (product.equals("peanuts") && city.equals("Sofia")) {
  47.             price = totalProduct * 1.6;
  48.         } else if (product.equals("peanuts") && city.equals("Plovdiv")) {
  49.             price = totalProduct * 1.5;
  50.         } else if (product.equals("peanuts") && city.equals("Varna")) {
  51.             price = totalProduct * 1.55;
  52.         }
  53.  
  54.         System.out.println(price);
  55.  
  56.    }
  57. }
Add Comment
Please, Sign In to add comment