martinvalchev

Small Shop

Oct 30th, 2017
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.83 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class SmallShop {
  4.     public static void main(String[] args) {
  5.         Scanner scanner = new Scanner(System.in);
  6.  
  7.         String product = scanner.nextLine().toLowerCase();
  8.         String town = scanner.nextLine().toLowerCase();
  9.         double qantity = Double.parseDouble(scanner.nextLine());
  10.         double price = -1;
  11.         double totall = -1;
  12.  
  13.         if (town.equals("sofia")) {
  14.             if (product.equals("coffee")) {
  15.                 price = 0.50;
  16.             } else if (product.equals("water")) {
  17.                 price = 0.80;
  18.             } else if (product.equals("beer")) {
  19.                 price = 1.20;
  20.             } else if (product.equals("sweets")) {
  21.                 price = 1.45;
  22.             } else if (product.equals("peanuts")) {
  23.                 price = 1.60;
  24.             }
  25.         } else if (town.equals("plovdiv")) {
  26.             if (product.equals("coffee")) {
  27.                 price = 0.40;
  28.             } else if (product.equals("water")) {
  29.                 price = 0.70;
  30.             } else if (product.equals("beer")) {
  31.                 price = 1.15;
  32.             } else if (product.equals("sweets")) {
  33.                 price = 1.30;
  34.             } else if (product.equals("peanuts")) {
  35.                 price = 1.50;
  36.             }
  37.         } else if (town.equals("varna")) {
  38.             if (product.equals("coffee")) {
  39.                 price = 0.45;
  40.             } else if (product.equals("water")) {
  41.                 price = 0.70;
  42.             } else if (product.equals("beer")) {
  43.                 price = 1.10;
  44.             } else if (product.equals("sweets")) {
  45.                 price = 1.35;
  46.             } else if (product.equals("peanuts")) {
  47.                 price = 1.55;
  48.             }
  49.         }
  50.         totall = price * qantity;
  51.         System.out.println(totall);
  52.     }
  53. }
Advertisement
Add Comment
Please, Sign In to add comment