Advertisement
pavsavov

Flowers U

Mar 4th, 2017
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.17 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class u2 {
  4. public static void main(String[] args) {
  5.  
  6. Scanner scanner = new Scanner(System.in);
  7.  
  8. int magnoliasNumber = Integer.parseInt(scanner.nextLine());
  9. int hyacinthusNumber = Integer.parseInt(scanner.nextLine());
  10. int rosesNumber = Integer.parseInt(scanner.nextLine());
  11. int cactusNumber = Integer.parseInt(scanner.nextLine());
  12. int giftPrice = Integer.parseInt(scanner.nextLine());
  13.  
  14. double magnolias = magnoliasNumber * 3.25;
  15. double hyacinthus = hyacinthusNumber * 4.00;
  16. double roses = rosesNumber * 3.50;
  17. double cactus = cactusNumber * 8.00;
  18.  
  19. double totalProfitWithoutTaxes = magnolias + hyacinthus + roses + cactus;
  20. double totalProfit = (totalProfitWithoutTaxes -(totalProfitWithoutTaxes*0.05));
  21. double neededMoney = Math.abs(totalProfit - giftPrice);
  22.  
  23.  
  24. if (totalProfit < giftPrice) {
  25. System.out.printf("She will have to borrow " + Math.ceil(neededMoney) + " leva.");
  26.  
  27. } else {
  28. System.out.println("She is left with " + Math.floor(neededMoney) + " leva.");
  29.  
  30.  
  31. }
  32.  
  33. }
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement