AsyaDamyanova

Fruit Shop

Oct 30th, 2019
204
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.90 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.         double price = 0.00;
  10.  
  11.         if ("Monday".equals(day)
  12.                 || "Tuesday".equals(day)
  13.                 || "Wednesday".equals(day)
  14.                 || "Thursday".equals(day)
  15.                 || "Friday".equals(day)) {
  16.             if ("banana".equals(fruit)) {
  17.                 price = 2.5;
  18.             } else if ("apple".equals(fruit)) {
  19.                 price = 1.2;
  20.             } else if ("orange".equals(fruit)) {
  21.                 price = 0.85;
  22.             } else if ("grapefruit".equals(fruit)) {
  23.                 price = 1.45;
  24.             } else if ("kiwi".equals(fruit)) {
  25.                 price = 2.7;
  26.             } else if ("pineapple".equals(fruit)) {
  27.                 price = 5.5;
  28.             } else if ("grapes".equals(fruit)) {
  29.                 price = 3.85;
  30.             }
  31.         } else if ("Saturday".equals(day) || "Sunday".equals(day)) {
  32.             if ("banana".equals(fruit)) {
  33.                 price = 2.7;
  34.             } else if ("apple".equals(fruit)) {
  35.                 price = 1.25;
  36.             } else if ("orange".equals(fruit)) {
  37.                 price = 0.90;
  38.             } else if ("grapefruit".equals(fruit)) {
  39.                 price = 1.60;
  40.             } else if ("kiwi".equals(fruit)) {
  41.                 price = 3;
  42.             } else if ("pineapple".equals(fruit)) {
  43.                 price = 5.6;
  44.             } else if ("grapes".equals(fruit)) {
  45.                 price = 4.20;
  46.             }
  47.         }
  48.         if (price > 0) {
  49.             System.out.printf("%.2f", quantity * price);
  50.         } else {
  51.             System.out.println("error");
  52.         }
  53.  
  54.     }
  55. }
Advertisement
Add Comment
Please, Sign In to add comment