Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class P02SmallShop {
- public static void main(String[] Arg) {
- Scanner scanner = new Scanner(System.in);
- double CoffeeSofia = 0.50;
- double CoffeePlovdiv = 0.40;
- double CoffeeVarna = 0.45;
- double WaterSofia = 0.80;
- double WaterPlovdiv = 0.70;
- double WaterVarna = 0.70;
- double BeerSofia = 1.20;
- double BeerPlovdiv = 1.15;
- double BeerVarna = 1.10;
- double SweetsSofia = 1.45;
- double SweetsPlovdiv = 1.30;
- double SweetsVarna = 1.35;
- double PeanutsSofia = 1.60;
- double PeanutsPlovdiv = 1.50;
- double PeanutsVarna = 1.55;
- String product = scanner.nextLine();
- String city = scanner.nextLine();
- double quantity = Double.parseDouble(scanner.nextLine());
- double Totalprice = 0;
- if (city.equalsIgnoreCase("Sofia")) {
- if (product.equalsIgnoreCase("Coffee")) {
- Totalprice = CoffeeSofia * quantity;
- } else if (product.equalsIgnoreCase("Water")) {
- Totalprice = WaterSofia * quantity;
- } else if (product.equalsIgnoreCase("Beer")) {
- Totalprice = BeerSofia * quantity;
- } else if (product.equalsIgnoreCase("Sweets")) {
- Totalprice = SweetsSofia * quantity;
- } else if (product.equalsIgnoreCase("Peanuts")) {
- Totalprice = PeanutsSofia * quantity;
- }
- } else if (city.equalsIgnoreCase("Plovdiv")) {
- if (product.equalsIgnoreCase("Coffee")) {
- Totalprice = CoffeePlovdiv * quantity;
- } else if (product.equalsIgnoreCase("Water")) {
- Totalprice = WaterPlovdiv * quantity;
- } else if (product.equalsIgnoreCase("Beer")) {
- Totalprice = BeerPlovdiv * quantity;
- } else if (product.equalsIgnoreCase("Sweets")) {
- Totalprice = SweetsPlovdiv * quantity;
- } else if (product.equalsIgnoreCase("Peanuts")) {
- Totalprice = PeanutsPlovdiv * quantity;
- }
- } else if (city.equalsIgnoreCase("Varna")) {
- if (product.equalsIgnoreCase("Coffee")) {
- Totalprice = CoffeeVarna * quantity;
- } else if (product.equalsIgnoreCase("Water")) {
- Totalprice = WaterVarna * quantity;
- } else if (product.equalsIgnoreCase("Beer")) {
- Totalprice = BeerVarna * quantity;
- } else if (product.equalsIgnoreCase("Sweets")) {
- Totalprice = SweetsVarna * quantity;
- } else if (product.equalsIgnoreCase("Peanuts")) {
- Totalprice = PeanutsVarna * quantity;
- }
- }
- System.out.println(Totalprice);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment