galinyotsev123

ProgBasicsExam22and23December2018-E02christmasMarket

Dec 30th, 2018
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.22 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class E02christmasMarket {
  4. public static void main(String[] args) {
  5. Scanner scanner = new Scanner(System.in);
  6.  
  7.  
  8. double targetMoney = Double.parseDouble(scanner.nextLine());
  9. double fantasyBooks = Double.parseDouble(scanner.nextLine());
  10. double horrorBooks = Double.parseDouble(scanner.nextLine());
  11. double romanceBooks = Double.parseDouble(scanner.nextLine());
  12.  
  13. double fantasyBookPrice = 14.90;
  14. double horrorBooksPrice = 9.80;
  15. double romanceBooksPrice = 4.30;
  16.  
  17. double CharityMoney = ((fantasyBookPrice * fantasyBooks)+(horrorBooks *horrorBooksPrice)+ (romanceBooks * romanceBooksPrice)) * 0.80;
  18.  
  19. if (CharityMoney >= targetMoney){
  20. double diff = CharityMoney - targetMoney;
  21. double sallers = Math.floor(diff * 0.10);
  22. double totalFinal = CharityMoney - sallers;
  23. System.out.printf("%.2f leva donated.%n", totalFinal);
  24. System.out.printf("Sellers will receive %.0f leva.", sallers);
  25.  
  26. }
  27.  
  28. else {
  29. double diff = targetMoney - CharityMoney;
  30. System.out.printf("%.2f money needed.", diff);
  31. }
  32.  
  33.  
  34.  
  35. }
  36. }
Advertisement
Add Comment
Please, Sign In to add comment