Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class shop {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- System.out.print("What product? : ");
- String product = scanner.nextLine();
- System.out.print("Which town? : ");
- String town = scanner.nextLine();
- town = town.substring(0, 1).toUpperCase()+ town.substring(1).toLowerCase();
- System.out.print("How much? : ");
- double amount = Double.parseDouble(scanner.nextLine());
- double price;
- if (product.equals("coffee") && town.equals("Sofia")) {
- price = amount * 0.50;
- System.out.printf("Price: %f\n", price);
- } else if (product.equals("coffee") && town.equals("Plovdiv")) {
- price = amount * 0.40;
- System.out.printf("Price: %f\n", price);
- } else if (product.equals("coffee") && town.equals("Varna")) {
- price = amount * 0.45;
- System.out.printf("Price: %f\n", price);
- } else if (product.equals("water") && town.equals("Sofia")) {
- price = amount * 0.80;
- System.out.printf("Price: %f\n", price);
- } else if (product.equals("water") && town.equals("Plovdiv")) {
- price = amount * 0.70;
- System.out.printf("Price: %f\n", price);
- } else if (product.equals("water") && town.equals("Varna")) {
- price = amount * 0.70;
- System.out.printf("Price: %f\n", price);
- } else if (product.equals("beer") && town.equals("Sofia")) {
- price = amount * 1.20;
- System.out.printf("Price: %f\n", price);
- } else if (product.equals("beer") && town.equals("Varna")) {
- price = amount * 1.10;
- System.out.printf("Price: %f\n", price);
- } else if (product.equals("beer") && town.equals("Plovdiv")) {
- price = amount * 1.15;
- System.out.printf("Price: %f\n", price);
- } else if (product.equals("sweets") && town.equals("Sofia")) {
- price = amount * 1.45;
- System.out.printf("Price: %f\n", price);
- } else if (product.equals("sweets") && town.equals("Plovdiv")) {
- price = amount * 1.30;
- System.out.printf("Price: %f\n", price);
- } else if (product.equals("sweets") && town.equals("Varna")) {
- price = amount * 1.35;
- System.out.printf("Price: %f\n", price);
- } else if (product.equals("peanuts") && town.equals("Sofia")) {
- price = amount * 1.60;
- System.out.printf("Price: %f\n", price);
- } else if (product.equals("peanuts") && town.equals("Plovdiv")) {
- price = amount * 1.50;
- System.out.printf("Price: %f\n", price);
- } else if (product.equals("peanuts") && town.equals("Varna")) {
- price = amount * 1.55;
- System.out.printf("Price: %f\n", price);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement