Advertisement
Guest User

Flowers

a guest
May 12th, 2019
306
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.36 KB | None | 0 0
  1.  
  2. import java.util.Scanner;
  3.  
  4. public class Main {
  5.     public static void main(String[] args) {
  6.  
  7.  
  8.         Scanner scanner = new Scanner(System.in);
  9.         int countOfChrysanthemum = Integer.parseInt(scanner.nextLine());
  10.         int countOfRoses = Integer.parseInt(scanner.nextLine());
  11.         int countOfTulips = Integer.parseInt(scanner.nextLine());
  12.         String season = scanner.nextLine();
  13.         String day = scanner.nextLine();
  14.         double priceAll = 0;
  15.  
  16.         switch (day) {
  17.             case "Y":
  18.                 if ("Spring".equals(season) || "Summer".equals(season)) {
  19.                     priceAll = countOfChrysanthemum * 2.00 + countOfRoses * 4.10 + countOfTulips * 2.50;
  20.                     priceAll = priceAll + (priceAll * 0.15);
  21.                     if (season.equals("Spring") && countOfTulips > 7) {
  22.                         priceAll = priceAll - (priceAll * 0.05);
  23.                     }
  24.  
  25.                 } else if ("Winter".equals(season) || "Autumn".equals(season)) {
  26.                     priceAll = countOfChrysanthemum * 3.75 + countOfRoses * 4.50 + countOfTulips * 4.15;
  27.                     priceAll = priceAll + (priceAll * 0.15);
  28.                     if (season.equals("Winter") && countOfRoses >= 10) {
  29.                         priceAll = priceAll - (priceAll * 0.10);
  30.                     }
  31.  
  32.                 }
  33.                 break;
  34.             case "N":
  35.                 if ("Spring".equals(season) || "Summer".equals(season)) {
  36.                     priceAll = countOfChrysanthemum * 2.00 + countOfRoses * 4.10 + countOfTulips * 2.50;
  37.                     if (season.equals("Spring") && countOfTulips > 7) {
  38.                         priceAll = priceAll - (priceAll * 0.05);
  39.                     }
  40.  
  41.                 } else if ("Winter".equals(season) || "Autumn".equals(season)) {
  42.                     priceAll = countOfChrysanthemum * 3.75 + countOfRoses * 4.50 + countOfTulips * 4.15;
  43.                     if (season.equals("Winter") && countOfRoses >= 10) {
  44.                         priceAll = priceAll - (priceAll * 0.10);
  45.                     }
  46.                 }
  47.                 break;
  48.         }
  49.         if (countOfChrysanthemum + countOfRoses + countOfTulips > 20) {
  50.             priceAll = (priceAll - (priceAll * 0.20)) + 2;
  51.         } else {
  52.             priceAll = priceAll + 2;
  53.         }
  54.         System.out.printf("%.2f", priceAll);
  55.     }
  56. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement