BubaLazi

p03_Flowers

Mar 9th, 2017
83
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.  
  7.         int broiHrizantemi = Integer.parseInt(console.nextLine());
  8.         int broiRozi = Integer.parseInt(console.nextLine());
  9.         int broiLaleta = Integer.parseInt(console.nextLine());
  10.  
  11.         String season = console.nextLine();
  12.         boolean isHoliday = console.nextLine().equals("Y");
  13.  
  14.         double hrizantemiPrice = 2.00;
  15.         double roziPrice = 4.10;
  16.         double laletaPrice = 2.50;
  17.  
  18.  
  19.  
  20.         switch (season) {
  21.             case "Autumn":
  22.             case "Winter":
  23.                 hrizantemiPrice = 3.75;
  24.                 roziPrice = 4.50;
  25.                 laletaPrice = 4.15;
  26.                 break;
  27.         }
  28.  
  29.         double totalPrice = (broiHrizantemi * hrizantemiPrice) + (broiRozi * roziPrice) + (broiLaleta * laletaPrice);
  30.  
  31.         if(isHoliday){
  32.             totalPrice += totalPrice * 0.15;
  33.         }
  34.         if (broiLaleta > 7 && season.equals("Spring")){
  35.             totalPrice -= totalPrice * 0.05;
  36.         }
  37.         if(broiRozi >= 10 && season.equals("Winter")){
  38.             totalPrice -= totalPrice * 0.10;
  39.         }
  40.  
  41.         if (broiHrizantemi + broiRozi + broiLaleta > 20){
  42.             totalPrice -= totalPrice * 0.20;
  43.         }
  44.  
  45.         final int instalationFee = 2;
  46.         totalPrice += instalationFee;
  47.  
  48.         System.out.printf("%.2f" , totalPrice);
  49.  
  50.     }
  51. }
Advertisement
Add Comment
Please, Sign In to add comment