Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class SmallShop_04 {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- String product = scanner.nextLine();
- String town = scanner.nextLine();
- double quantity = Double.parseDouble(scanner.nextLine());
- //Sofia, Plovdiv, Varna
- switch (town) {
- case "Sofia":
- switch (product) {
- case "coffee":
- System.out.println(quantity * 0.5);
- break;
- case "water":
- System.out.println(quantity * 0.80);
- break;
- case "beer":
- System.out.println(quantity * 1.20);
- break;
- case "sweets":
- System.out.println(quantity * 1.45);
- break;
- case "peanuts":
- System.out.println(quantity * 1.60);
- break;
- }
- //какво правим ако сме в София
- break;
- case "Plovdiv":
- switch (product) {
- case "coffee":
- System.out.println(quantity * 0.4);
- break;
- case "water":
- System.out.println(quantity * 0.70);
- break;
- case "beer":
- System.out.println(quantity * 1.15);
- break;
- case "sweets":
- System.out.println(quantity * 1.30);
- break;
- case "peanuts":
- System.out.println(quantity * 1.50);
- break;
- }
- //какво правим ако сме в Пловдив
- break;
- case "Varna":
- //какво правим ако сме във Варна
- switch (product) {
- case "coffee":
- System.out.println(quantity * 0.45);
- break;
- case "water":
- System.out.println(quantity * 0.70);
- break;
- case "beer":
- System.out.println(quantity * 1.10);
- break;
- case "sweets":
- System.out.println(quantity * 1.35);
- break;
- case "peanuts":
- System.out.println(quantity * 1.55);
- break;
- }
- break;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement