deyanivanov966

03. New House

Aug 29th, 2020 (edited)
173
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.63 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class NewHouse {
  4.     public static void main(String[] args) {
  5.         Scanner scanner= new Scanner(System.in);
  6.         String flower=scanner.nextLine();
  7.         int counter=Integer.parseInt(scanner.nextLine());
  8.         int budget=Integer.parseInt(scanner.nextLine());
  9.         double total=0;
  10.         if (flower.equals("Roses"))
  11.         {
  12.             total=counter*5;
  13.             if (counter>80)
  14.             {
  15.                 total=total*0.9;
  16.             }
  17.         }
  18.         else if (flower.equals("Dahlias"))
  19.         {
  20.             total=counter*3.80;
  21.             if (counter>90)
  22.             {
  23.                 total=total*0.85;
  24.             }
  25.         }
  26.         else if (flower.equals("Tulips"))
  27.         {
  28.             total=counter*2.80;
  29.             if (counter>80)
  30.             {
  31.                 total=total*0.85;
  32.             }
  33.         }
  34.         else if (flower.equals("Narcissus"))
  35.         {
  36.             total=counter*3.0;
  37.             if (counter<120)
  38.             {
  39.                 total+=total*0.15;
  40.             }
  41.         }
  42.         else if (flower.equals("Gladiolus"))
  43.         {
  44.             total=counter*2.50;
  45.             if (counter<80)
  46.             {
  47.                 total+=total*0.2;
  48.             }
  49.         }
  50.         if (budget<total)
  51.         {
  52.             double diff=total-budget;
  53.             System.out.printf("Not enough money, you need %.2f leva more.",diff);
  54.  
  55.         }
  56.         else
  57.         {
  58.             double diff=budget-total;
  59.             System.out.printf("Hey, you have a great garden with %d %s and %.2f leva left.",counter,flower,diff);
  60.         }
  61.  
  62.     }
  63. }
Add Comment
Please, Sign In to add comment