Advertisement
desislava_topuzakova

2. Small Shop

May 13th, 2018
205
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.91 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Shop {
  4.     public static void main(String[] agrs) {
  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.         double price = 0;
  12.  
  13.         if (town.equalsIgnoreCase("Sofia")) {
  14.             if (product.equals("coffee")) {
  15.                 price = 0.50 * quantity;
  16.             } else if (product.equals("water")) {
  17.                 price = 0.80 * quantity;
  18.             } else if (product.equals("beer")) {
  19.                 price = 1.20 * quantity;
  20.             } else if (product.equals("sweets")) {
  21.                 price = 1.45 * quantity;
  22.             } else if (product.equals("peanuts")) {
  23.                 price = 1.60 * quantity;
  24.             }
  25.         } else if (town.equals("Plovdiv")) {
  26.             if (product.equals("coffee")) {
  27.                 price = 0.40 * quantity;
  28.             } else if (product.equals("water")) {
  29.                 price = 0.70 * quantity;
  30.             } else if (product.equals("beer")) {
  31.                 price = 1.15 * quantity;
  32.             } else if (product.equals("sweets")) {
  33.                 price = 1.30 * quantity;
  34.             } else if (product.equals("peanuts")) {
  35.                 price = 1.50 * quantity;
  36.             }
  37.         }else if (town.equals("Varna")){
  38.             if (product.equals("coffee")) {
  39.                 price = 0.45 * quantity;
  40.             } else if (product.equals("water")) {
  41.                 price = 0.70 * quantity;
  42.             } else if (product.equals("beer")) {
  43.                 price = 1.10 * quantity;
  44.             } else if (product.equals("sweets")) {
  45.                 price = 1.35 * quantity;
  46.             } else if (product.equals("peanuts")) {
  47.                 price = 1.55 * quantity;
  48.             }
  49.         }
  50.  
  51.         System.out.println(price);
  52.     }
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement