Helena12

New House

Oct 29th, 2018
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.68 KB | None | 0 0
  1. import java.io.PrintStream;
  2. import java.util.Scanner;
  3.  
  4. public class EP05NewHome {
  5.     public static void main(String[] args) {
  6.         Scanner scanner = new Scanner(System.in);
  7.  
  8.         String flowerType = scanner.nextLine();
  9.         int flowersAmount = Integer.parseInt(scanner.nextLine());
  10.         int budget = Integer.parseInt(scanner.nextLine());
  11.  
  12.         double price = 0;
  13.  
  14.         if(flowerType.equalsIgnoreCase("Roses")) {
  15.             price = flowersAmount * 5;
  16.             if (flowersAmount > 80) {
  17.                 price *= 0.9;
  18.             }
  19.         }
  20. else if (flowerType.equalsIgnoreCase("Dahlias")) {
  21.     price = flowersAmount * 3.8;
  22.     if (flowersAmount > 90) {
  23.         price *= 0.85;
  24.     }
  25.         }
  26.         else if (flowerType.equalsIgnoreCase("Tulips")) {
  27.             price = flowersAmount * 2.8;
  28.             if (flowersAmount > 80) {
  29.                 price *= 0.85;
  30.             }
  31.         }
  32.         else if (flowerType.equalsIgnoreCase("Narcissus")) {
  33.             price = flowersAmount * 3;
  34.             if (flowersAmount < 120) {
  35.                 price += (price * 0.15);
  36.             }
  37.         }
  38.         else if(flowerType.equalsIgnoreCase("Gladiolus")) {
  39.             price = flowersAmount * 2.50;
  40.             if (flowersAmount < 80) {
  41.                 price += (price * 0.20);
  42.             }
  43.         }
  44.         double difference = Math.abs(budget - price);
  45.  
  46.         if (budget >= price) {
  47.             System.out.printf("Hey, you have a great garden with %d %s and %.2f leva left.", flowersAmount, flowerType, difference);
  48.         }
  49.         else {
  50.             System.out.printf("Not enough money, you need %.2f leva more.", difference);
  51.         }
  52.     }
  53. }
Advertisement
Add Comment
Please, Sign In to add comment