Advertisement
psi_mmobile

Untitled

May 9th, 2022
875
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.59 KB | None | 0 0
  1. public class MyClass {
  2.     public static void main(String args[]) {
  3.         java.util.Scanner scanner = new java.util.Scanner(System.in);
  4.         String fruit = scanner.nextLine();
  5.         String setSize = scanner.nextLine();
  6.         int numberOfSets = scanner.nextInt();
  7.        
  8.         double watermelonPrice = 0.0;
  9.         double mangoPrice = 0.0;
  10.         double pineapplePrice = 0.0;
  11.         double raspberryPrice = 0.0;
  12.        
  13.         if (setSize.equals("small")) {
  14.             watermelonPrice = 56.00 * 2;
  15.             mangoPrice = 36.66 * 2;
  16.             pineapplePrice = 42.10 * 2;
  17.             raspberryPrice = 20.00 * 2;
  18.         } else {
  19.             watermelonPrice = 28.70 * 5;
  20.             mangoPrice = 19.60 * 5;
  21.             pineapplePrice = 24.80 * 5;
  22.             raspberryPrice = 15.20 * 5;
  23.         }
  24.        
  25.         double totalPrice = 0.0;
  26.        
  27.         switch(fruit) {
  28.             case "Watermelon" : totalPrice = watermelonPrice * numberOfSets;
  29.             break;
  30.             case "Mango" : totalPrice = mangoPrice * numberOfSets;
  31.             break;
  32.             case "Pineapple" : totalPrice = pineapplePrice * numberOfSets;
  33.             break;
  34.             case "Raspberry" : totalPrice = raspberryPrice * numberOfSets;
  35.             break;
  36.         }
  37.        
  38.         if (totalPrice >= 400 && totalPrice <= 1000) {
  39.             totalPrice = totalPrice * 0.85;
  40.         } else if (totalPrice < 400)  {
  41.             totalPrice = totalPrice;
  42.         } else {
  43.             totalPrice = totalPrice * 0.5;
  44.         }
  45.         System.out.printf("%.2f lv.",totalPrice);
  46.     }
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement