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 scan = new Scanner(System.in);
- String fruit = scan.nextLine();
- String day = scan.nextLine();
- double quantity = Double.parseDouble(scan.nextLine());
- double price = 0;
- if ("Monday".equals(day) || "Tuesday".equals(day) || "Wednesday".equals(day) || "Thursday".equals(day) || "Friday".equals(day)) {
- if (fruit.equals("banana")) {
- price = quantity * 2.5;
- } else if (fruit.equals("apple")) {
- price = quantity * 1.20;
- } else if (fruit.equals("orange")) {
- price = quantity * 0.85;
- } else if (fruit.equals("grapefruit")) {
- price = quantity * 1.45;
- } else if (fruit.equals("kiwi")) {
- price = quantity * 2.70;
- } else if (fruit.equals("pineapple")) {
- price = quantity * 5.50;
- } else if (fruit.equals("grapes")) {
- price = quantity * 3.85;
- } else {
- System.out.println("error");
- }
- } else if ("Saturday".equals(day) || "Sunday".equals(day)) {
- if (fruit.equals("banana")) {
- price = quantity * 2.7;
- } else if (fruit.equals("apple")) {
- price = quantity * 1.25;
- } else if (fruit.equals("orange")) {
- price = quantity * 0.9;
- } else if (fruit.equals("grapefruit")) {
- price = quantity * 1.6;
- } else if (fruit.equals("kiwi")) {
- price = quantity * 3.0;
- } else if (fruit.equals("pineapple")) {
- price = quantity * 5.60;
- } else if (fruit.equals("grapes")) {
- price = quantity * 4.2;
- } else {
- System.out.println("error");
- }
- System.out.println(price);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement