Advertisement
psi_mmobile

Untitled

Apr 22nd, 2022
1,127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.01 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 flowerType = scanner.nextLine();
  7.         int flowerAmount = Integer.parseInt(scanner.nextLine());
  8.         int budget = Integer.parseInt(scanner.nextLine());
  9.         double rosesPrice = 5.00;
  10.         double dahliasPrice = 3.80;
  11.         double tulipsPrice = 2.80;
  12.         double narcissusPrice = 3.00;
  13.         double gladiolusPrice = 2.50;
  14.         double totalIncome = 0.0;
  15.         switch (flowerType) {
  16.             case "Roses":
  17.                 totalIncome = flowerAmount * rosesPrice;
  18.                 if (flowerAmount > 80) {
  19.                     totalIncome = totalIncome * 0.90;
  20.                 }
  21.                 break;
  22.             case "Dahlias":
  23.                 totalIncome = flowerAmount * dahliasPrice;
  24.                 if (flowerAmount > 90) {
  25.                     totalIncome = totalIncome * 0.85;
  26.                 }
  27.                 break;
  28.             case "Tulips":
  29.                 totalIncome = flowerAmount * tulipsPrice;
  30.                 if (flowerAmount > 80) {
  31.                     totalIncome = totalIncome * 0.85;
  32.                 }
  33.                 break;
  34.             case "Narcissus":
  35.                 totalIncome = flowerAmount * narcissusPrice;
  36.                if (flowerAmount < 120) {
  37.                    totalIncome = totalIncome * 1.15;
  38.                 }
  39.                 break;
  40.             case "Gladiolus":
  41.                 totalIncome = flowerAmount * gladiolusPrice;
  42.                 if (flowerAmount < 80) {
  43.                     totalIncome = totalIncome * 1.20;
  44.                 }
  45.                 break;
  46.         }
  47.         if (totalIncome <= budget) {
  48.             System.out.printf("Hey, you have a great garden with %d %s and %.2f leva left.", flowerAmount, flowerType, (budget - totalIncome));
  49.         } else {
  50.             System.out.printf("Not enough money, you need %.2f leva more.", (totalIncome - budget));
  51.         }
  52.     }
  53. }
  54.  
  55.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement