Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package TasksWeek3;
- import java.util.Scanner;
- public class _11_FruitShop {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- String fruit = scanner.nextLine();
- String weekday = scanner.nextLine();
- double number = Double.parseDouble(scanner.nextLine());
- double price = 0.0;
- switch (weekday) {
- case "Monday","Tuesday","Wednesday","Thursday","Friday" -> {
- if (fruit.equals("banana"))
- price = number * 2.50;
- else if (fruit.equals("apple"))
- price = number * 1.20;
- else if (fruit.equals("orange"))
- price = number * 0.85;
- else if (fruit.equals("grapefruit"))
- price = number * 1.45;
- else if (fruit.equals("kiwi"))
- price = number * 2.70;
- else if (fruit.equals("pineapple"))
- price = number * 5.50;
- else if (fruit.equals("grapes"))
- price = number * 3.85;
- else
- System.out.println("error");
- }
- case "Saturday","Sunday" -> {
- if (fruit.equals("banana"))
- price = number * 2.70;
- else if (fruit.equals("apple"))
- price = number * 1.25;
- else if (fruit.equals("orange"))
- price = number * 0.90;
- else if (fruit.equals("grapefruit"))
- price = number * 1.60;
- else if (fruit.equals("kiwi"))
- price = number * 3.00;
- else if (fruit.equals("pineapple"))
- price = number * 5.60;
- else if (fruit.equals("grapes"))
- price = number * 4.20;
- else
- System.out.println("error");
- }
- default -> System.out.println("error");
- }
- if (price != 0.0) {
- System.out.printf("%.2f",price);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement