Advertisement
zlatinnn

Untitled

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