Advertisement
YavorGrancharov

Flowers

Mar 18th, 2017
326
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.46 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Flowers {
  4.     public static void main(String[] args) {
  5.         Scanner console = new Scanner(System.in);
  6.         int chrysanthemum = Integer.parseInt(console.nextLine());
  7.         int roses = Integer.parseInt(console.nextLine());
  8.         int tulips = Integer.parseInt(console.nextLine());
  9.         String season = console.nextLine();
  10.         String holliday = console.nextLine();
  11.  
  12.         double priceChrysanthemum = 0.0;
  13.         double priceRoses = 0.0;
  14.         double priceTulips = 0.0;
  15.         double flowers = chrysanthemum + roses + tulips;
  16.  
  17.         if (season.equals("Summer") || season.equals("Spring")) {
  18.             priceChrysanthemum = chrysanthemum * 2.00;
  19.             priceRoses = roses * 4.10;
  20.             priceTulips = tulips * 2.50;
  21.         }
  22.  
  23.         if (season.equals("Winter") || season.equals("Autumn")) {
  24.             priceChrysanthemum = chrysanthemum * 3.75;
  25.             priceRoses = roses * 4.50;
  26.             priceTulips = tulips * 4.15;
  27.  
  28.         }
  29.  
  30.         double price = priceChrysanthemum + priceRoses + priceTulips;
  31.  
  32.         if (season.equals("Spring") && tulips > 7) {
  33.             price *= 0.95;
  34.         }
  35.         if (season.equals("Winter") && roses >= 10) {
  36.             price *= 0.90;
  37.         }
  38.         if (flowers > 20) {
  39.             price *= 0.80;
  40.         } else if (holliday.equals("Y")) {
  41.             price *= 1.15;
  42.         }
  43.         System.out.printf("%.2f", price + 2);
  44.     }
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement