Advertisement
todor_boichev

Untitled

Sep 5th, 2020
344
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 PROBA {
  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 ("sofia".equals(town)){
  13.             if ("coffee".equals(products)){
  14.                 productPrice = 0.5;
  15.             }else if ("water".equals(products)){
  16.                 productPrice = 0.8;
  17.             }else if ("beer".equals(products)){
  18.                 productPrice = 1.2;
  19.             }else if ("sweets".equals(products)){
  20.                 productPrice = 1.45;
  21.             }else if ("peanuts".equals(products)){
  22.                 productPrice = 1.6;
  23.             }
  24.         }else if ("plovdiv".equals(town)){
  25.             if ("coffee".equals(products)){
  26.                 productPrice = 0.4;
  27.             }else if ("water".equals(products)){
  28.                 productPrice = 0.7;
  29.             }else if ("beer".equals(products)){
  30.                 productPrice = 1.15;
  31.             }else if ("sweets".equals(products)){
  32.                 productPrice = 1.3;
  33.             }else if ("peanuts".equals(products)){
  34.                 productPrice = 1.5;
  35.             }
  36.         }else if ("varna".equals(town)){
  37.             if ("coffee".equals(products)){
  38.                 productPrice = 0.45;
  39.             }else if ("water".equals(products)){
  40.                 productPrice = 0.7;
  41.             }else if ("beer".equals(products)){
  42.                 productPrice = 1.1;
  43.             }else if ("sweets".equals(products)){
  44.                 productPrice = 1.35;
  45.             }else if ("peanuts".equals(products)){
  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