Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class SmallShop {
- 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());
- double productPrice = 0;
- switch (town) {
- case "Sofia":
- if (product.equals("coffee")) {
- productPrice = 0.5;
- } else if (product.equals("water")) {
- productPrice = 0.8;
- } else if (product.equals("beer")) {
- productPrice = 1.20;
- } else if (product.equals("sweets")) {
- productPrice = 1.40;
- } else if (product.equals("peanuts")) {
- productPrice = 1.60;
- }
- break;
- case "Plovdiv":
- if (product.equals("coffee")) {
- productPrice = 0.4;
- } else if (product.equals("water")) {
- productPrice = 0.7;
- } else if (product.equals("beer")) {
- productPrice = 1.15;
- } else if (product.equals("sweets")) {
- productPrice = 1.30;
- } else if (product.equals("peanuts")) {
- productPrice = 1.50;
- }
- break;
- case "Varna":
- if (product.equals("coffee")) {
- productPrice = 0.45;
- } else if (product.equals("water")) {
- productPrice = 0.70;
- } else if (product.equals("beer")) {
- productPrice = 1.10;
- } else if (product.equals("sweets")) {
- productPrice = 1.35;
- } else if (product.equals("peanuts")) {
- productPrice = 1.55;
- }
- break;
- }
- double totalPrice = productPrice*quantity;
- System.out.println(totalPrice);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement