ThunDerStorm26

Flower Shop

Jan 22nd, 2021 (edited)
245
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.20 KB | None | 0 0
  1. package com.company;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class FlowerShop {
  6.  
  7.     public static void main(String[] args) {
  8.  
  9.         Scanner scanner = new Scanner(System.in);
  10.  
  11.         int magnolias = Integer.parseInt(scanner.nextLine());
  12.         int hyacinth = Integer.parseInt(scanner.nextLine());
  13.         int roses = Integer.parseInt(scanner.nextLine());
  14.         int cactus = Integer.parseInt(scanner.nextLine());
  15.         double present = Double.parseDouble(scanner.nextLine());
  16.  
  17.         double magnoliasPrice = magnolias * 3.25;
  18.         double hyacinthPrice = hyacinth * 4;
  19.         double rosesPrice = roses * 3.50;
  20.         double cactusPrice = cactus * 8;
  21.  
  22.         double money = magnoliasPrice + hyacinthPrice + rosesPrice + cactusPrice;
  23.         double rate = money * 0.05;
  24.         double profit = money - rate;
  25.  
  26.  
  27.         if (present > profit){
  28.             int moneyDifferent = (int) Math.ceil(present - profit);
  29.             System.out.printf("She will have to borrow %d leva.", moneyDifferent);
  30.         }
  31.         else {
  32.             int moneyDifferent = (int) Math.floor(profit - present);
  33.             System.out.printf("She is left with %d leva.", moneyDifferent);
  34.         }
  35.  
  36.  
  37.     }
  38.  
  39. }
  40.  
Add Comment
Please, Sign In to add comment