Mishakis

FruitShop

Jul 18th, 2017
154
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.33 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Main {
  4.  
  5.     public static void main(String[] args) {
  6.         Scanner Scanner = new Scanner(System.in);
  7.  
  8.  
  9.         String product = Scanner.nextLine();
  10.         String dayOfWeek = Scanner.nextLine();
  11.         double quantity = Double.parseDouble(Scanner.nextLine());
  12.         double price = 0;
  13.  
  14.         if(dayOfWeek.equalsIgnoreCase("Monday") || (dayOfWeek.equalsIgnoreCase("Tuesday")) ||
  15.                 (dayOfWeek.equalsIgnoreCase("Wednesday")) || (dayOfWeek.equalsIgnoreCase("Thursday"))
  16.                 || (dayOfWeek.equalsIgnoreCase("Friday"))){
  17.             if(product.equalsIgnoreCase("banana")){
  18.                 price = quantity * 2.5;
  19.             }else if (product.equalsIgnoreCase("apple")){
  20.                 price = quantity * 1.2;
  21.             }else if(product.equalsIgnoreCase("orange")){
  22.                 price = quantity * 0.85;
  23.             }else if (product.equalsIgnoreCase("grapefruit")){
  24.                 price = quantity * 1.45;
  25.             }else if(product.equalsIgnoreCase("kiwi")){
  26.                 price = quantity * 2.7;
  27.             }else if(product.equalsIgnoreCase("pineapple")){
  28.                 price = quantity * 5.5;
  29.             }else if(product.equalsIgnoreCase("grapes")){
  30.                 price = quantity * 3.85;
  31.             }else{
  32.                 System.out.println("error");
  33.             }
  34.  
  35.         }else if(dayOfWeek.equalsIgnoreCase("Saturday") || (dayOfWeek.equalsIgnoreCase("Sunday"))){
  36.             if(product.equalsIgnoreCase("banana")){
  37.                 price = quantity * 2.7;
  38.             }else if (product.equalsIgnoreCase("apple")){
  39.                 price = quantity * 1.25;
  40.             }else if(product.equalsIgnoreCase("orange")){
  41.                 price = quantity * 0.9;
  42.             }else if (product.equalsIgnoreCase("grapefruit")){
  43.                 price = quantity * 1.60;
  44.             }else if(product.equalsIgnoreCase("kiwi")){
  45.                 price = quantity * 3;
  46.             }else if(product.equalsIgnoreCase("pineapple")){
  47.                 price = quantity * 5.6;
  48.             }else if(product.equalsIgnoreCase("grapes")){
  49.                 price = quantity * 4.2;
  50.             }else{
  51.                 System.out.println("error");
  52.             }
  53.         }else{
  54.             System.out.println("error");
  55.         }
  56.         System.out.println(price);
  57.     }
  58. }
Advertisement
Add Comment
Please, Sign In to add comment