Guest User

Untitled

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