Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package _04_Polymorphism.EXERCISES;
- import java.util.Scanner;
- public class test {
- public static void main(String[] args) {
- Scanner console = new Scanner(System.in);
- String product = console.nextLine().toLowerCase();
- String city = console.nextLine().toLowerCase();
- Double quantity = Double.parseDouble(console.nextLine());
- double price = -1;
- if (city.equals("sofia")) {
- if (product.equals("coffee")) {
- price = 0.50;
- } else if (product.equals("water")) {
- price = 0.80;
- } else if (product.equals("beer")) {
- price = 1.20;
- } else if (product.equals("sweets")) {
- price = 1.45;
- } else if (product.equals("peanuts")) {
- price = 1.60;
- }
- } else if (city.equals("plovdiv")) {
- if (product.equals("coffee")) {
- price = 0.40;
- } else if (product.equals("water")) {
- price = 0.70;
- } else if (product.equals("beer")) {
- price = 1.15;
- } else if (product.equals("sweets")) {
- price = 1.30;
- } else if (product.equals("peanuts")) {
- price = 1.50;
- }
- } else if (city.equals("varna")) {
- if (product.equals("coffee")) {
- price = 0.45;
- } else if (product.equals("water")) {
- price = 0.70;
- } else if (product.equals("beer")) {
- price = 1.10;
- } else if (product.equals("sweets")) {
- price = 1.35;
- } else if (product.equals("peanuts")) {
- price = 1.55;
- }
- }
- double endPrice = quantity * price;
- System.out.println(endPrice);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement