Advertisement
Sim0o0na

ChristmasMarket

Jul 4th, 2019
223
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.17 KB | None | 0 0
  1. package com.company;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class ChristmasMarket {
  6. public static void main(String[] args) {
  7. Scanner scanner = new Scanner(System.in);
  8.  
  9. double targetMoney = Double.parseDouble(scanner.nextLine());
  10. int fantasyBooksCount = Integer.parseInt(scanner.nextLine());
  11. int horrorBooksCount = Integer.parseInt(scanner.nextLine());
  12. int romanceBooksCount = Integer.parseInt(scanner.nextLine());
  13.  
  14. double totalSum = 0;
  15. totalSum += fantasyBooksCount * 14.9;
  16. totalSum += horrorBooksCount * 9.80;
  17. totalSum += romanceBooksCount * 4.3;
  18.  
  19. totalSum -= totalSum * 0.2;
  20.  
  21. if (totalSum >= targetMoney) {
  22. double moneyAboveTarget = totalSum - targetMoney;
  23. double sellersSalary = moneyAboveTarget * 0.1;
  24. sellersSalary = Math.floor(sellersSalary);
  25. totalSum -= sellersSalary;
  26. System.out.printf("%.2f leva donated.%n", totalSum);
  27. System.out.printf("Sellers will receive %.0f leva.", sellersSalary);
  28. } else {
  29. System.out.printf("%.2f money needed.", targetMoney - totalSum);
  30. }
  31. }
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement