Advertisement
galinyotsev123

ProgBasicsExam3and4November2018-E02maidenParty

Dec 30th, 2018
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.38 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class E02maidenParty {
  4. public static void main(String[] args) {
  5. Scanner scanner = new Scanner(System.in);
  6.  
  7.  
  8. double price = Double.parseDouble(scanner.nextLine());
  9. double loveLetters = Double.parseDouble(scanner.nextLine());
  10. double roses = Double.parseDouble(scanner.nextLine());
  11. double key = Double.parseDouble(scanner.nextLine());
  12. double cartoons = Double.parseDouble(scanner.nextLine());
  13. double surprise = Double.parseDouble(scanner.nextLine());
  14.  
  15. double totalNumItems = loveLetters + roses + key + cartoons + surprise;
  16.  
  17. double loveLettersPrice = 0.60 * loveLetters;
  18. double rosesPrice = 7.2 * roses;
  19. double keyPrice = 3.60 * key;
  20. double cartoonPrice = 18.20 * cartoons;
  21. double surpricePrice = 22 * surprise;
  22.  
  23. double totalPrice = loveLettersPrice + rosesPrice + keyPrice + cartoonPrice + surpricePrice;
  24. if (totalNumItems >= 25)
  25. {
  26. totalPrice = 0.65 * totalPrice;
  27. }
  28. double hosting = 0.1 * totalPrice;
  29. double profit = totalPrice - hosting;
  30. if (profit > price)
  31. {
  32. System.out.printf("Yes! %.2f lv left.", profit-price);
  33. }
  34. else
  35. {
  36. System.out.printf("Not enough money! %.2f lv needed.",price - profit);
  37. }
  38. }
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement