Helena12

Fruit Shop

Oct 29th, 2018
155
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.53 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class FruitShop {
  4.     public static void main(String[] args) {
  5.         Scanner scanner = new Scanner(System.in);
  6.         String fruit = scanner.nextLine();
  7.         String day = scanner.nextLine();
  8.         double quantity = Double.parseDouble(scanner.nextLine());
  9.  
  10.         double price = -1.0;
  11.  
  12.         if (day.equals("Monday") || day.equals("Tuesday") || day.equals("Wednesday") ||
  13.         day.equals("Thursday") || day.equals("Friday")) {
  14.             if (fruit.equals("banana")) price = 2.50;
  15.             else if (fruit.equals("apple")) price = 1.20;
  16.             else if (fruit.equals("orange")) price = 0.85;
  17.             else if (fruit.equals("grapefruit")) price = 1.45;
  18.             else if (fruit.equals("kiwi")) price = 2.70;
  19.             else if (fruit.equals("pineapple")) price = 5.50;
  20.             else if (fruit.equals("grapes")) price = 3.85;
  21.  
  22.         } else if (day.equals("Saturday") || day.equals("Sunday")) {
  23.             if (fruit.equals("banana")) price = 2.70;
  24.             else if (fruit.equals("apple")) price = 1.25;
  25.             else if (fruit.equals("orange")) price = 0.90;
  26.             else if (fruit.equals("grapefruit")) price = 1.60;
  27.             else if (fruit.equals("kiwi")) price = 3.00;
  28.             else if (fruit.equals("pineapple")) price = 5.60;
  29.             else if (fruit.equals("grapes")) price = 4.20;
  30.         }
  31.         if (price >= 0) {
  32.             System.out.println(price * quantity);
  33.         } else {
  34.             System.out.println("error");
  35.         }
  36.  
  37.  
  38.     }
  39. }
Advertisement
Add Comment
Please, Sign In to add comment