Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Project: Complex_Conditions - created by borkins on 2017-03-26.
- */
- import java.util.Scanner;
- public class _07_FruitShop
- {
- public static void main(String[] args)
- {
- Scanner console = new Scanner(System.in);
- String fruit = console.nextLine().toLowerCase();
- String day = console.nextLine().toLowerCase();
- double quantity = Double.parseDouble(console.nextLine());
- double price = -1;
- boolean isWorkday = day.equals("monday") || day.equals("tuesday") ||
- day.equals("wednesday") || day.equals("thursday") ||
- day.equals("friday");
- boolean isWeekend = day.equals("saturday") || day.equals("sunday");
- if (isWorkday)
- {
- switch (fruit)
- {
- case "banana":
- price = 2.50;
- break;
- case "apple":
- price = 1.20;
- break;
- case "orange":
- price = 0.85;
- break;
- case "grapefruit":
- price = 1.45;
- break;
- case "kiwi":
- price = 2.70;
- break;
- case "pineapple":
- price = 5.50;
- break;
- case "grapes":
- price = 3.85;
- break;
- }
- }
- else if (isWeekend)
- {
- switch (fruit)
- {
- case "banana":
- price = 2.70;
- break;
- case "apple":
- price = 1.25;
- break;
- case "orange":
- price = 0.90;
- break;
- case "grapefruit":
- price = 1.60;
- break;
- case "kiwi":
- price = 3.00;
- break;
- case "pineapple":
- price = 5.60;
- break;
- case "grapes":
- price = 4.20;
- break;
- }
- }
- if (price >= 0) {
- System.out.println(price * quantity);
- }
- else {
- System.out.println("error");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment