Advertisement
todor_boichev

Untitled

Sep 5th, 2020
287
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 SmallShop {
  4.     public static void main(String[] args) {
  5.         Scanner scanner = new Scanner(System.in);
  6.         String products = scanner.nextLine().toLowerCase();
  7.         String town = scanner.nextLine().toLowerCase();
  8.         double quantity = Double.parseDouble(scanner.nextLine());
  9.  
  10.         double productPrice = 0;
  11.  
  12.         if (town.equals("sofia")){
  13.             if (products.equals("coffee")){
  14.                 productPrice = 0.5;
  15.             }else if (products.equals("water")){
  16.                 productPrice = 0.8;
  17.             }else if (products.equals("beer")){
  18.                 productPrice = 1.2;
  19.             }else if (products.equals("sweets")){
  20.                 productPrice = 1.45;
  21.             }else if (products.equals("peanuts")){
  22.                 productPrice = 1.6;
  23.             }
  24.         }else if (town.equals("plovdiv")){
  25.             if (products.equals("coffee")){
  26.                 productPrice = 0.4;
  27.             }else if (products.equals("water")){
  28.                 productPrice = 0.7;
  29.             }else if (products.equals("beer")){
  30.                 productPrice = 1.15;
  31.             }else if (products.equals("sweet")){
  32.                 productPrice = 1.3;
  33.             }else if (products.equals("peanuts")){
  34.                 productPrice = 1.5;
  35.             }
  36.         }else if (town.equals("varna")){
  37.             if (products.equals("coffee")){
  38.                 productPrice = 0.45;
  39.             }else if (products.equals("water")){
  40.                 productPrice = 0.7;
  41.             }else if (products.equals("beer")){
  42.                 productPrice = 1.1;
  43.             }else if (products.equals("sweets")){
  44.                 productPrice = 1.35;
  45.             }else if (products.equals("peanuts")){
  46.                 productPrice = 1.55;
  47.             }
  48.         }
  49.         double total = quantity * productPrice;
  50.         System.out.printf("%.2f", total);
  51.  
  52.     }
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement