Dido09

02.ChristmasMarket

Nov 1st, 2019
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.10 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class ChristmasMarket {
  4. public static void main(String[] args) {
  5. Scanner scanner = new Scanner(System.in);
  6.  
  7. double neededMoney = Double.parseDouble(scanner.nextLine());
  8. int fantasyCount = Integer.parseInt(scanner.nextLine());
  9. int horrorCount = Integer.parseInt(scanner.nextLine());
  10. int romanceCount = Integer.parseInt(scanner.nextLine());
  11.  
  12. double fantasyPrice = 14.9;
  13. double horrorPrice = 9.8;
  14. double romancePrice = 4.3;
  15.  
  16. double totalPrice = fantasyCount * fantasyPrice + horrorCount * horrorPrice + romanceCount * romancePrice;
  17.  
  18. totalPrice *= 0.8;
  19.  
  20. if (totalPrice >= neededMoney ){
  21. double rest = totalPrice - neededMoney;
  22. int temp = (int)Math.floor(rest * 0.1);
  23. totalPrice -= temp;
  24.  
  25. System.out.printf("%.2f leva donated.%n", totalPrice);
  26. System.out.printf("Sellers will receive %d leva.", temp);
  27.  
  28. }else{
  29. System.out.printf("%.2f money needed.", neededMoney - totalPrice);
  30. }
  31.  
  32. }
  33. }
Add Comment
Please, Sign In to add comment