Advertisement
Guest User

Flowers

a guest
May 12th, 2019
1,407
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.57 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.  
  15.         int sumOfFlowers = countOfChrysanthemum + countOfRoses + countOfTulips;
  16.  
  17.         double chrysanthemumPrice = 0.0;
  18.         double rosesPrice = 0.0;
  19.         double tulipsPrice = 0.0;
  20.  
  21.         if (season.equals("Spring") || season.equals("Summer")) {
  22.             chrysanthemumPrice = countOfChrysanthemum * 2.00;
  23.             rosesPrice = countOfRoses * 4.10;
  24.             tulipsPrice = countOfTulips * 2.5;
  25.         } else if (season.equals("Autumn") || season.equals("Winter")) {
  26.             chrysanthemumPrice =  countOfChrysanthemum  * 3.75;
  27.             rosesPrice= countOfRoses  * 4.50;
  28.             tulipsPrice  = countOfTulips * 4.15;
  29.         }
  30.         double totalSum = chrysanthemumPrice + rosesPrice + tulipsPrice ;
  31.  
  32.         if (day.equals( "Y")) {
  33.             totalSum *= 1.15;
  34.         }
  35.         if (season.equals("Spring") && countOfTulips >= 7) {
  36.             totalSum *= 0.95;
  37.         }
  38.         if (season.equals( "Winter") && countOfRoses >= 10) {
  39.             totalSum *= 0.9;
  40.         }
  41.         if (sumOfFlowers >= 20) {
  42.             totalSum *= 0.8;
  43.         }
  44.         System.out.printf("%.2f",totalSum + 2);
  45.     }
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement