Advertisement
Guest User

Untitled

a guest
Nov 14th, 2020
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.96 KB | None | 0 0
  1. package ConditionalStatementsAdvanced.Lab;
  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.         String product = scanner.nextLine();
  9.         String town = scanner.nextLine();
  10.         double quantity = Double.parseDouble(scanner.nextLine());
  11.  
  12.         double total = 0.0;
  13.  
  14.  
  15.         if (town.equals("Sofia")) {
  16.             if (product.equals("coffee")) {
  17.                 total = quantity * 0.5;
  18.             } else if (product.equals("water")) {
  19.                 total = quantity * 0.8;
  20.             } else if (product.equals("beer")) {
  21.                 total = quantity * 1.2;
  22.             } else if (product.equals("sweets")) {
  23.                 total = quantity * 1.45;
  24.             } else if (product.equals("peanuts")) {
  25.                 total = quantity * 1.60;
  26.             }
  27.         }
  28.         if (town.equals("Plovdiv")) {
  29.             if (product.equals("coffee")) {
  30.                 total = quantity * 0.4;
  31.             } else if (product.equals("water")) {
  32.                 total = quantity * 0.7;
  33.             } else if (product.equals("beer")) {
  34.                 total = quantity * 1.15;
  35.             } else if (product.equals("sweets")) {
  36.                 total = quantity * 1.30;
  37.             } else if (product.equals("peanuts")) {
  38.                 total = quantity * 1.50;
  39.             }
  40.         }
  41.  
  42.         if (town.equals("Varna")) {
  43.             if (product.equals("coffee")) {
  44.                 total = quantity * 0.45;
  45.             } else if (product.equals("water")) {
  46.                 total = quantity * 0.7;
  47.             } else if (product.equals("beer")) {
  48.                 total = quantity * 1.10;
  49.             } else if (product.equals("sweets")) {
  50.                 total = quantity * 1.35;
  51.             } else if (product.equals("peanuts")) {
  52.                 total = quantity * 1.55;
  53.             }
  54.         }
  55.  
  56.         System.out.println(total);
  57.     }
  58. }
  59.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement