daily pastebin goal
44%
SHARE
TWEET

7. Fruit Shop

Alex_Matarov May 16th, 2018 100 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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.  
  7.         String fruit = scanner.nextLine();
  8.         String dayOfWeek = scanner.nextLine();
  9.         double quantity = Double.parseDouble(scanner.nextLine());
  10.         double price = 0;
  11.  
  12.         if (dayOfWeek.equals("Monday")
  13.                 || dayOfWeek.equals("Tuesday")
  14.                 || dayOfWeek.equals("Wednesday")
  15.                 || dayOfWeek.equals("Thursday")
  16.                 || dayOfWeek.equals("Friday")) {
  17.             if (fruit.equals("banana")) {
  18.                 price = 2.50 * quantity;
  19.                 System.out.println(price);
  20.             } else if (fruit.equals("apple")) {
  21.                 price = 1.20 * quantity;
  22.                 System.out.println(price);
  23.             } else if (fruit.equals("orange")) {
  24.                 price = 0.85 * quantity;
  25.                 System.out.println(price);
  26.             } else if (fruit.equals("grapefruit")) {
  27.                 price = 1.45 * quantity;
  28.                 System.out.println(price);
  29.             } else if (fruit.equals("kiwi")) {
  30.                 price = 2.70 * quantity;
  31.                 System.out.println(price);
  32.             } else if (fruit.equals("pineapple")) {
  33.                 price = 5.50 * quantity;
  34.                 System.out.println(price);
  35.             } else if (fruit.equals("grapes")) {
  36.                 price = 3.85 * quantity;
  37.                 System.out.println(price);
  38.             } else {
  39.                 System.out.println("error");
  40.             }
  41.  
  42.         } else if (dayOfWeek.equals("Saturday")
  43.                 || dayOfWeek.equals("Sunday")) {
  44.             if (fruit.equals("banana")) {
  45.                 price = 2.70 * quantity;
  46.                 System.out.println(price);
  47.             } else if (fruit.equals("apple")) {
  48.                 price = 1.25 * quantity;
  49.                 System.out.println(price);
  50.             } else if (fruit.equals("orange")) {
  51.                 price = 0.90 * quantity;
  52.                 System.out.println(price);
  53.             } else if (fruit.equals("grapefruit")) {
  54.                 price = 1.60 * quantity;
  55.                 System.out.println(price);
  56.             } else if (fruit.equals("kiwi")) {
  57.                 price = 3.00 * quantity;
  58.                 System.out.println(price);
  59.             } else if (fruit.equals("pineapple")) {
  60.                 price = 5.60 * quantity;
  61.                 System.out.println(price);
  62.             } else if (fruit.equals("grapes")) {
  63.                 price = 4.20 * quantity;
  64.                 System.out.println(price);
  65.             }else {
  66.                 System.out.println("error");
  67.             }
  68.  
  69.  
  70.  
  71.         }
  72.         else {
  73.             System.out.println("error");
  74.         }
  75.     }
  76.  
  77.  
  78. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top