Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Shop_05 {
- public static void main(String[] args) {
- Scanner myScan = new Scanner(System.in);
- String product = myScan.nextLine();
- String town = myScan.nextLine();
- double order = Double.parseDouble(myScan.nextLine());
- double totalPriceOrder = 0;
- // town check - Sofia Plovdiv Varna
- switch (town) {
- case "Sofia":
- switch (product) {
- case "coffee":
- totalPriceOrder = order * 0.50;
- System.out.println(totalPriceOrder);
- break;
- case "water":
- totalPriceOrder = order * 0.80;
- System.out.println(totalPriceOrder);
- break;
- case "beer":
- totalPriceOrder = order * 1.20;
- System.out.println(totalPriceOrder);
- break;
- case "sweets":
- totalPriceOrder = order * 1.45;
- System.out.println(totalPriceOrder);
- break;
- case "peanuts":
- totalPriceOrder = order * 1.60;
- System.out.println(totalPriceOrder);
- break;
- }
- break;
- case "Plovdiv":
- switch (product) {
- case "coffee":
- totalPriceOrder = order * 0.40;
- System.out.println(totalPriceOrder);
- break;
- case "water":
- totalPriceOrder = order * 0.70;
- System.out.println(totalPriceOrder);
- break;
- case "beer":
- totalPriceOrder = order * 1.15;
- System.out.println(totalPriceOrder);
- break;
- case "sweets":
- totalPriceOrder = order * 1.30;
- System.out.println(totalPriceOrder);
- break;
- case "peanuts":
- totalPriceOrder = order * 1.50;
- System.out.println(totalPriceOrder);
- break;
- }
- break;
- case "Varna":
- switch (product) {
- case "coffee":
- totalPriceOrder = order * 0.45;
- System.out.println(totalPriceOrder);
- break;
- case "water":
- totalPriceOrder = order * 0.70;
- System.out.println(totalPriceOrder);
- break;
- case "beer":
- totalPriceOrder = order * 1.10;
- System.out.println(totalPriceOrder);
- break;
- case "sweets":
- totalPriceOrder = order * 1.35;
- System.out.println(totalPriceOrder);
- break;
- case "peanuts":
- totalPriceOrder = order * 1.55;
- System.out.println(totalPriceOrder);
- break;
- }
- break;
- }
- }
- }
Add Comment
Please, Sign In to add comment