Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package ConditionalStatementsAdvanced.Lab;
- 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 total = 0.0;
- if (town.equals("Sofia")) {
- if (product.equals("coffee")) {
- total = quantity * 0.5;
- } else if (product.equals("water")) {
- total = quantity * 0.8;
- } else if (product.equals("beer")) {
- total = quantity * 1.2;
- } else if (product.equals("sweets")) {
- total = quantity * 1.45;
- } else if (product.equals("peanuts")) {
- total = quantity * 1.60;
- }
- }
- if (town.equals("Plovdiv")) {
- if (product.equals("coffee")) {
- total = quantity * 0.4;
- } else if (product.equals("water")) {
- total = quantity * 0.7;
- } else if (product.equals("beer")) {
- total = quantity * 1.15;
- } else if (product.equals("sweets")) {
- total = quantity * 1.30;
- } else if (product.equals("peanuts")) {
- total = quantity * 1.50;
- }
- }
- if (town.equals("Varna")) {
- if (product.equals("coffee")) {
- total = quantity * 0.45;
- } else if (product.equals("water")) {
- total = quantity * 0.7;
- } else if (product.equals("beer")) {
- total = quantity * 1.10;
- } else if (product.equals("sweets")) {
- total = quantity * 1.35;
- } else if (product.equals("peanuts")) {
- total = quantity * 1.55;
- }
- }
- System.out.println(total);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement