Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class __FruitShop {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- String fruit = scanner.nextLine();
- String dayFromWeek = scanner.nextLine();
- double quantity = Double.parseDouble(scanner.nextLine());
- double productPrice = 0;
- double totalSum = 0;
- if (dayFromWeek.equals("Monday") || dayFromWeek.equals("Tuesday") ||
- dayFromWeek.equals("Wednesday") || dayFromWeek.equals("Thursday") ||
- dayFromWeek.equals("Friday")) {
- switch (fruit) {
- case "banana":
- productPrice = 2.5;
- break;
- case "apple":
- productPrice = 1.2;
- break;
- case "orange":
- productPrice = 0.85;
- break;
- case "grapefruit":
- productPrice = 1.45;
- break;
- case "kiwi":
- productPrice = 2.7;
- break;
- case "pineapple":
- productPrice = 5.5;
- break;
- case "grapes":
- productPrice = 3.85;
- break;
- }
- totalSum = productPrice * quantity;
- System.out.printf("%.2f", totalSum);
- }
- if (dayFromWeek.equals("Saturday") || dayFromWeek.equals("Sunday")) {
- switch (fruit) {
- case "banana":
- productPrice = 2.7;
- break;
- case "apple":
- productPrice = 1.25;
- break;
- case "orange":
- productPrice = 0.9;
- break;
- case "grapefruit":
- productPrice = 1.6;
- break;
- case "kiwi":
- productPrice = 3;
- break;
- case "pineapple":
- productPrice = 5.6;
- break;
- case "grapes":
- productPrice = 4.2;
- break;
- }
- totalSum = productPrice * quantity;
- System.out.printf("%.2f", totalSum);
- } else {
- System.out.println("error");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement