Advertisement
kallyy7

Untitled

Mar 3rd, 2018
260
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.25 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class zadacha2 {
  4.  
  5.  
  6.     public static void main(String[] args) {
  7.         Scanner scanner = new Scanner(System.in);
  8.  
  9.         String produckt = scanner.nextLine();
  10.         String town = scanner.nextLine().toLowerCase();
  11.         double quantity = Double.parseDouble(scanner.nextLine());
  12.         double result = 0;
  13.         if (town.equalsIgnoreCase("Sofia")) {
  14.             if (produckt.equalsIgnoreCase("coffee")) {
  15.                 result = quantity * 0.5;
  16.             } else if (produckt.equalsIgnoreCase("water")) {
  17.                 result = quantity * 0.8;
  18.             } else if (produckt.equalsIgnoreCase("beer")) {
  19.                 result = quantity * 1.2;
  20.             } else if (produckt.equalsIgnoreCase("sweets")) {
  21.                 result = quantity * 1.45;
  22.             } else if (produckt.equalsIgnoreCase("peanuts")) {
  23.                 result = quantity * 1.60;
  24.             }
  25.         }
  26.         if (town.equalsIgnoreCase("Plovdiv")) {
  27.                 if (produckt.equalsIgnoreCase("coffee")) {
  28.                     result = quantity * 0.4;
  29.                 } else if (produckt.equalsIgnoreCase("water")) {
  30.                     result = quantity * 0.7;
  31.                 } else if (produckt.equalsIgnoreCase("beer")) {
  32.                     result = quantity * 1.15;
  33.                 } else if (produckt.equalsIgnoreCase("sweets")) {
  34.                     result = quantity * 1.3;
  35.                 } else if (produckt.equalsIgnoreCase("peanuts")) {
  36.                     result = quantity * 1.5;
  37.                 }
  38.         }
  39.         if (town.equalsIgnoreCase("Varna")) {
  40.                     if (produckt.equalsIgnoreCase("coffee")) {
  41.                         result = quantity * 0.45;
  42.                     } else if (produckt.equalsIgnoreCase("water")) {
  43.                         result = quantity * 0.7;
  44.                     } else if (produckt.equalsIgnoreCase("beer")) {
  45.                         result = quantity * 1.1;
  46.                     } else if (produckt.equalsIgnoreCase("sweets")) {
  47.                         result = quantity * 1.35;
  48.                     } else if (produckt.equalsIgnoreCase("peanuts")) {
  49.                         result = quantity * 1.55;
  50.                     }
  51.         }
  52.          System.out.println(result);
  53.     }
  54. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement