Untitled

 avatar
unknown
plain_text
4 years ago
2.2 kB
40
Indexable
import com.sun.security.jgss.GSSUtil;

import java.util.Locale;
import java.util.Scanner;

public class demo {
    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 pricePerProduct = 0;

        if(town.equals("Sofia")){
            if(product.equals("coffee")) {
                pricePerProduct = 0.50;
            } else if (product.equals("water")) {
                pricePerProduct = 0.80;
            } else if (product.equals("beer")){
                pricePerProduct = 1.20;
            } else if (product.equals("sweets")) {
                pricePerProduct = 1.45;
            } else if(product.equals("peanuts")) {
                pricePerProduct = 1.60;
            }
        } else if(town.equals("Plovdiv")) {
            if(product.equals("coffee")) {
                pricePerProduct = 0.40;
            } else if (product.equals("water")) {
                pricePerProduct = 0.70;
            } else if (product.equals("beer")){
                pricePerProduct = 1.15;
            } else if (product.equals("sweets")) {
                pricePerProduct = 1.30;
            } else if(product.equals("peanuts")) {
                pricePerProduct = 1.50;
            }
        } else if (town.equals("Varna")) {
            if(product.equals("coffee")) {
                pricePerProduct = 0.45;
            } else if (product.equals("water")) {
                pricePerProduct = 0.70;
            } else if (product.equals("beer")){
                pricePerProduct = 1.10;
            } else if (product.equals("sweets")) {
                pricePerProduct = 1.35;
            } else if(product.equals("peanuts")) {
                pricePerProduct = 1.55;
            }
        }
        //ед.цена
        double totalSum = quantity * pricePerProduct;
        System.out.println(totalSum);

    }
}
Editor is loading...