SHARE
TWEET

Fruit Shop

a guest Jun 25th, 2019 90 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package com.company;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class FruitShop {
  6.     public static void main(String[] args) {
  7.         Scanner scanner = new Scanner(System.in);
  8.         String fruit = scanner.nextLine();
  9.         String dayOfWeek = scanner.nextLine().toLowerCase();
  10.         double quantity = Double.parseDouble(scanner.nextLine());
  11.         double price = 0;
  12.  
  13.         if ((dayOfWeek == "monday") || (dayOfWeek == "tuesday") || (dayOfWeek == "wednesday") || (dayOfWeek == "thursday") ||
  14.                 (dayOfWeek == "friday")) ;
  15.         {
  16.             if (fruit == "banana") {
  17.                 price = 2.50;
  18.             } else if (fruit == "apple") {
  19.                 price = 1.20;
  20.             } else if (fruit == "orange") {
  21.                 price = 0.85;
  22.             } else if (fruit == "grapefruit") {
  23.                 price = 1.45;
  24.             } else if (fruit == "kiwi") {
  25.                 price = 2.70;
  26.             } else if (fruit == "pineapple") {
  27.                 price = 5.50;
  28.             } else if (fruit == "grapes") {
  29.                 price = 3.85;
  30.             }
  31.             if ((dayOfWeek == "saturday") || (dayOfWeek == "sunday")) {
  32.                 if (fruit == "banana") {
  33.                     price = 2.70;
  34.                 } else if (fruit == "apple") {
  35.                     price = 1.25;
  36.                 } else if (fruit == "orange") {
  37.                     price = 0.90;
  38.                 } else if (fruit == "grapefruit") {
  39.                     price = 1.60;
  40.                 } else if (fruit == "kiwi") {
  41.                     price = 3;
  42.                 } else if (fruit == "pineapple") {
  43.                     price = 5.60;
  44.                 } else if (fruit == "grapes") {
  45.                     price = 4.20;
  46.                 }
  47.                 if (price > 0) {
  48.                     System.out.println(price * quantity);
  49.                 } else {
  50.                     System.out.println("error");
  51.                 }
  52.             }
  53.  
  54.         }
  55.     }
  56. }
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
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top