SHARE
TWEET

Untitled

a guest Jun 26th, 2019 55 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. import java.util.Scanner;
  3.  
  4. public class Program {
  5.     public static void main(String[] args) {
  6.         Scanner scanner = new Scanner(System.in);
  7.         //declaring variables
  8.         String flowerType = scanner.nextLine();
  9.         //"Roses", "Dahlias", "Tulips", "Narcissus", "Gladiolus"
  10.         int flowerCount = Integer.parseInt (scanner.nextLine());
  11.         int budget = Integer.parseInt (scanner.nextLine());
  12.  
  13.         double price = 0;
  14.         //initialize prices
  15.         if(flowerType.equals("Roses")){
  16.             price=5;
  17.         }else if (flowerType.equals("Dahlias")){
  18.                 price=3.8;
  19.         }else if (flowerType.equals("Tulips")){
  20.                 price=2.8;
  21.         }else if (flowerType.equals("Narcissus")){
  22.                 price=3;
  23.         }else if (flowerType.equals("Gladiolus")){
  24.                 price=2.5;
  25.         }
  26.  
  27.  
  28.         if(flowerType.equals("Roses")&&flowerCount>80){
  29.             price *= 0.9;
  30.         }else if(flowerType.equals("Dahlias")&&flowerCount>90){
  31.             price*=0.85;
  32.         }else if (flowerType.equals("Tulips")&&flowerCount>80){
  33.             price*=0.85;
  34.         }else if (flowerType.equals("Narcissus")&&flowerCount<120){
  35.             price +=price*0.15;
  36.         }else if (flowerType.equals("Gladiolus")&&flowerCount<80){
  37.             price+=price*0.2;
  38.         }
  39.  
  40.         double finalPrice = price*flowerCount;
  41.  
  42.         if(budget>finalPrice){
  43.             double remainings = budget-finalPrice;
  44.             System.out.printf("Hey, you have a great garden with %d %s and %.2f leva left.",flowerCount,flowerType,remainings);
  45.         }else{
  46.             double lack = finalPrice-budget;
  47.             System.out.printf("Not enough money, you need %.2f leva more.", lack);
  48.         }
  49.  
  50.  
  51.  
  52.     }
  53. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top