Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.company;
- import java.util.Scanner;
- public class FruitShop {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- String fruit = scanner.nextLine();
- String dayOfWeek = scanner.nextLine().toLowerCase();
- double quantity = Double.parseDouble(scanner.nextLine());
- double price = 0;
- if ((dayOfWeek == "monday") || (dayOfWeek == "tuesday") || (dayOfWeek == "wednesday") || (dayOfWeek == "thursday") ||
- (dayOfWeek == "friday")) ;
- {
- if (fruit == "banana") {
- price = 2.50;
- } else if (fruit == "apple") {
- price = 1.20;
- } else if (fruit == "orange") {
- price = 0.85;
- } else if (fruit == "grapefruit") {
- price = 1.45;
- } else if (fruit == "kiwi") {
- price = 2.70;
- } else if (fruit == "pineapple") {
- price = 5.50;
- } else if (fruit == "grapes") {
- price = 3.85;
- }
- if ((dayOfWeek == "saturday") || (dayOfWeek == "sunday")) {
- if (fruit == "banana") {
- price = 2.70;
- } else if (fruit == "apple") {
- price = 1.25;
- } else if (fruit == "orange") {
- price = 0.90;
- } else if (fruit == "grapefruit") {
- price = 1.60;
- } else if (fruit == "kiwi") {
- price = 3;
- } else if (fruit == "pineapple") {
- price = 5.60;
- } else if (fruit == "grapes") {
- price = 4.20;
- }
- if (price > 0) {
- System.out.println(price * quantity);
- } else {
- System.out.println("error");
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement