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 day = scanner.nextLine();
- double quantity = Double.parseDouble(scanner.nextLine());
- double price = 0.00;
- if ("Monday".equals(day)
- || "Tuesday".equals(day)
- || "Wednesday".equals(day)
- || "Thursday".equals(day)
- || "Friday".equals(day)) {
- if ("banana".equals(fruit)) {
- price = 2.5;
- } else if ("apple".equals(fruit)) {
- price = 1.2;
- } else if ("orange".equals(fruit)) {
- price = 0.85;
- } else if ("grapefruit".equals(fruit)) {
- price = 1.45;
- } else if ("kiwi".equals(fruit)) {
- price = 2.7;
- } else if ("pineapple".equals(fruit)) {
- price = 5.5;
- } else if ("grapes".equals(fruit)) {
- price = 3.85;
- }
- } else if ("Saturday".equals(day) || "Sunday".equals(day)) {
- if ("banana".equals(fruit)) {
- price = 2.7;
- } else if ("apple".equals(fruit)) {
- price = 1.25;
- } else if ("orange".equals(fruit)) {
- price = 0.90;
- } else if ("grapefruit".equals(fruit)) {
- price = 1.60;
- } else if ("kiwi".equals(fruit)) {
- price = 3;
- } else if ("pineapple".equals(fruit)) {
- price = 5.6;
- } else if ("grapes".equals(fruit)) {
- price = 4.20;
- }
- }
- if (price > 0) {
- System.out.printf("%.2f", quantity * price);
- } else {
- System.out.println("error");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment