Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class CoffeeMachine_03 {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- String name = scanner.nextLine();
- String sugar = scanner.nextLine();
- int numDrinks = Integer.parseInt(scanner.nextLine());
- double price = 0.00;
- if (name.equals("Espresso")) {
- if (sugar.equals("Without")){
- price = numDrinks * 0.9;
- price = price - (0.35 * price);
- }
- else if (sugar.equals("Normal")){
- price = numDrinks * 1.00;
- }
- else {
- price = numDrinks * 1.20;
- }
- if (numDrinks >= 5){
- price = price - (price * 0.25);
- }
- }
- else if (name.equals("Cappuccino")) {
- if (sugar.equals("Without")){
- price = numDrinks * 1.00;
- price = price - (0.35 * price);
- }
- else if (sugar.equals("Normal")){
- price = numDrinks * 1.20;
- }
- else {
- price = numDrinks * 1.60;
- }
- }
- else {
- if (sugar.equals("Without")){
- price = numDrinks * 0.5;
- price = price - (0.35 * price);
- }
- else if (sugar.equals("Normal")){
- price = numDrinks * 0.50;
- }
- else {
- price = numDrinks * 0.70;
- }
- }
- if (price >= 15) {
- price = price - (0.20 * price);
- }
- System.out.printf("You bought %d cups of %s for %.2f lv.", numDrinks, name, price);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement