Advertisement
Guest User

Untitled

a guest
Nov 27th, 2020
209
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.27 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Proba {
  4.     public static void main(String[] args) {
  5.         Scanner scanner = new Scanner(System.in);
  6.  
  7.         String typeFlower = scanner.nextLine();
  8.         int numFlower = Integer.parseInt(scanner.nextLine());
  9.         int budget = Integer.parseInt(scanner.nextLine());
  10.  
  11.         double rosePrice = 5 * numFlower;
  12.         double dahliaPrice = 3.8 * numFlower;
  13.         double tulipsPrice = 2.8 * numFlower;
  14.         double narcissusPrice = 3 * numFlower;
  15.         double gladiolusPrice = 2.5 * numFlower;
  16.  
  17.         double totalPrice = 0.0;
  18.  
  19.         if (typeFlower.equalsIgnoreCase("roses") && numFlower > 80) {
  20.             totalPrice = rosePrice - rosePrice * 0.1;
  21.         } else if (typeFlower.equalsIgnoreCase("roses") && numFlower <= 80) {
  22.             totalPrice = rosePrice;
  23.         } else if (typeFlower.equalsIgnoreCase("dahlias") && numFlower > 90) {
  24.             totalPrice = dahliaPrice - dahliaPrice * 0.15;
  25.         } else if (typeFlower.equalsIgnoreCase("dahlias") && numFlower <= 90) {
  26.             totalPrice = dahliaPrice;
  27.         } else if (typeFlower.equalsIgnoreCase("tulips") && numFlower > 80) {
  28.             totalPrice = tulipsPrice - tulipsPrice * 0.15;
  29.         } else if ((typeFlower.equalsIgnoreCase("tulips") && numFlower <= 80)) {
  30.             totalPrice = tulipsPrice;
  31.         } else if (typeFlower.equalsIgnoreCase("narcissus") && numFlower < 120) {
  32.             totalPrice = narcissusPrice + narcissusPrice * 0.15;
  33.         } else if (typeFlower.equalsIgnoreCase("narcissus") && numFlower >= 120) {
  34.             totalPrice = narcissusPrice;
  35.         } else if (typeFlower.equalsIgnoreCase("gladiolus") && numFlower < 80) {
  36.             totalPrice = gladiolusPrice + gladiolusPrice * 0.2;
  37.         } else if (typeFlower.equalsIgnoreCase("gladiolus") && numFlower >= 80) {
  38.             totalPrice = gladiolusPrice;
  39.         }
  40.  
  41.         if (budget >= totalPrice) {
  42.             double leftMoney = budget - totalPrice;
  43.             System.out.printf("Hey, you have a great garden with %d %s and %.2f leva left.", numFlower, typeFlower, leftMoney);
  44.         } else {
  45.             double neededMoney = totalPrice - budget;
  46.             System.out.printf("Not enough money, you need %.2f leva more.", neededMoney);
  47.         }
  48.  
  49.  
  50.     }
  51. }
  52.  
  53.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement