Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class MyClass {
- public static void main(String args[]) {
- Scanner scanner = new Scanner(System.in);
- String product = scanner.next();
- String city = scanner.next();
- int quantity = scanner.nextInt();
- double coffeePrice = 0.45;
- double waterPrice = 0.7;
- double beerPrice = 1.1;
- double sweetsPrice = 1.35;
- double peanutsPrice = 1.55;
- switch (city) {
- case "Sofia" : coffeePrice += 0.05; waterPrice += 0.1; beerPrice += 0.1; sweetsPrice += 0.1; peanutsPrice +=0.05; break;
- case "Plovdiv" : coffeePrice -= 0.05; beerPrice += 0.05; sweetsPrice -= 0.05; peanutsPrice -= 0.05; break;
- }
- switch (product) {
- case "coffee" : System.out.printf("%.2f", coffeePrice * quantity); break;
- case "water" : System.out.printf("%.2f", waterPrice * quantity); break;
- case "beer" : System.out.printf("%.2f", beerPrice * quantity); break;
- case "sweets" : System.out.printf("%.2f", sweetsPrice * quantity); break;
- case "peanuts" : System.out.printf("%.2f", peanutsPrice * quantity); break;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement