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 drink = scanner.next();
- String sugar = scanner.next();
- int numberOfOrders = scanner.nextInt();
- double espressoPrice = 0.9;
- double cappuccinoPrice = 1.0;
- double teaPrice = 0.5;
- double totalPrice = 0.0;
- double discount = 0.0;
- switch (sugar) {
- case "Normal" : espressoPrice += 0.1; cappuccinoPrice += 0.2; teaPrice += 0.1; break;
- case "Extra" : espressoPrice += 0.3; cappuccinoPrice += 0.6; teaPrice += 0.2; break;
- default : discount = 0.35;
- }
- switch (drink) {
- case "Espresso" : totalPrice = numberOfOrders * espressoPrice * (1 - discount); break;
- case "Cappuccino" : totalPrice = numberOfOrders * cappuccinoPrice * (1 - discount); break;
- default : totalPrice = numberOfOrders * teaPrice * (1 - discount);
- }
- if (drink.equals("Espresso") && numberOfOrders >= 5) {
- totalPrice = totalPrice * 0.75;
- }
- if (totalPrice > 15) {
- totalPrice = totalPrice * 0.8;
- }
- System.out.printf("You bought %d cups of %s for %.2f lv.",numberOfOrders,drink,totalPrice);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement