Advertisement
Guest User

Untitled

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