Advertisement
anonymous2222

Untitled

Nov 2nd, 2019
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.07 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class FlowerShop {
  4. public static void main(String[] args) {
  5. Scanner scan = new Scanner(System.in);
  6. double magnoliaPrice = 3.25;
  7. int hyacinthsPrice = 4;
  8. double rosesPrice = 3.5;
  9. int cactusPrice = 8;
  10.  
  11. int magnoliaCount = Integer.parseInt(scan.nextLine());
  12. int hyacinthsCount = Integer.parseInt(scan.nextLine());
  13. int rosesCount = Integer.parseInt(scan.nextLine());
  14. int cactusCount = Integer.parseInt(scan.nextLine());
  15. double giftPrice = Integer.parseInt(scan.nextLine());
  16.  
  17. double totalPrice = magnoliaCount * magnoliaPrice + hyacinthsCount * hyacinthsPrice + rosesCount * rosesPrice +
  18. cactusCount * cactusPrice;
  19.  
  20. double taxes = totalPrice / 0.5;
  21.  
  22. if (totalPrice >= giftPrice) {
  23. System.out.println("She is left with %.2ф leva." + Math.floor(taxes - totalPrice));
  24. } else {
  25. System.out.println("She will have to borrow %.2ф leva." + Math.floor(giftPrice - taxes));
  26. }
  27. }
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement