Advertisement
Spocoman

03. Flowers

Aug 26th, 2024
48
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.13 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 chrysanthemums = Integer.parseInt(scanner.nextLine());
  7.         int roses = Integer.parseInt(scanner.nextLine());
  8.         int tulips = Integer.parseInt(scanner.nextLine());
  9.         String season = scanner.nextLine();
  10.         String holiday = scanner.nextLine();
  11.  
  12.         double sum = 0;
  13.  
  14.         if (season.equals("Spring") || season.equals("Summer")) {
  15.             sum = 2.00 * chrysanthemums + 4.10 * roses + 2.50 * tulips;
  16.         } else if (season.equals("Autumn") || season.equals("Winter")) {
  17.             sum = 3.75 * chrysanthemums + 4.5 * roses + 4.15 * tulips;
  18.         }
  19.         if (holiday.equals("Y")) {
  20.             sum *= 1.15;
  21.         }
  22.         if (tulips > 7 && season.equals("Spring")) {
  23.             sum *= 0.95;
  24.         }
  25.         if (roses >= 10 && season.equals("Winter")) {
  26.             sum *= 0.90;
  27.         }
  28.         if (chrysanthemums + roses + tulips > 20) {
  29.             sum *= 0.80;
  30.         }
  31.  
  32.         System.out.printf("%.2f\n", sum + 2);
  33.     }
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement