SHARE
TWEET

fruitShop

a guest Jun 25th, 2019 67 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.             if (fruit == "banana") {
  16.                 price = 2.50;
  17.             } else if (fruit == "apple") {
  18.                 price = 1.20;
  19.             } else  if (fruit == "orange") {
  20.                 price = 0.85;
  21.             } else  if (fruit == "grapefruit") {
  22.                 price = 1.45;
  23.             } else  if (fruit == "kiwi") {
  24.                 price = 2.70;
  25.             } else if (fruit == "pineapple") {
  26.                 price = 5.50;
  27.             } else if (fruit == "grapes") {
  28.                 price = 3.85;
  29.             }
  30.             if ((dayOfWeek == "saturday") || (dayOfWeek == "sunday")) {
  31.                 if (fruit == "banana") {
  32.                     price = 2.70;
  33.                 } else if (fruit == "apple") {
  34.                     price = 1.25;
  35.                 } else  if (fruit == "orange") {
  36.                     price = 0.90;
  37.                 } else  if (fruit == "grapefruit") {
  38.                     price = 1.60;
  39.                 } else  if (fruit == "kiwi") {
  40.                     price = 3;
  41.                 } else if (fruit == "pineapple") {
  42.                     price = 5.60;
  43.                 } else if (fruit == "grapes") {
  44.                     price = 4.20;
  45.                 }
  46.                 System.out.println(price*quantity);
  47.             } else {
  48.                 System.out.println("error");
  49.             }
  50.            }
  51.  
  52.         }
  53.     }
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