Advertisement
Guest User

Untitled

a guest
Dec 15th, 2018
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.97 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class fuitShop {
  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;
  10.  
  11.         if (day.equals("Monday") || day.equals("Tuesday") || day.equals("Wednesday") || day.equals("Thursday") || day.equals("Friday")) {
  12.             if (fruit.equals("banana")) {
  13.                 price = quantity * 2.50;
  14.             } else if (fruit.equals("apple")) {
  15.                 price = quantity * 1.20;
  16.             } else if (fruit.equals("orange")) {
  17.                 price = quantity * 0.85;
  18.             } else if (fruit.equals("grapefruit")) {
  19.                 price = quantity * 1.45;
  20.             } else if (fruit.equals("kiwi")) {
  21.                 price = quantity * 2.70;
  22.             } else if (fruit.equals("pineapple")) {
  23.                 price = quantity * 5.50;
  24.             } else if (fruit.equals("grapes")) {
  25.                 price = quantity * 3.85;
  26.             }
  27.         } else if (day.equals("Saturday") || day.equals("Sunday") ) {
  28.             if (fruit.equals("banana")) {
  29.                 price = quantity * 2.70;
  30.             } else if (fruit.equals("apple")) {
  31.                 price = quantity * 1.25;
  32.             } else if (fruit.equals("orange")) {
  33.                 price = quantity * 0.90;
  34.             } else if (fruit.equals("grapefruit")) {
  35.                 price = quantity * 1.60;
  36.             } else if (fruit.equals("kiwi")) {
  37.                 price = quantity * 3.00;
  38.             } else if (fruit.equals("pineapple")) {
  39.                 price = quantity * 5.60;
  40.             } else if (fruit.equals("grapes")) {
  41.                 price = quantity * 4.20;
  42.             }
  43.         }
  44.  
  45.         if (price > 0) {
  46.             System.out.printf("%.2f", price);
  47.         } else {
  48.             System.out.println("error");
  49.         }
  50.     }
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement