Advertisement
Edzhevit

ToyShop

Sep 23rd, 2018
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.11 KB | None | 0 0
  1. package OldExams;
  2.  
  3. import java.util.Scanner;
  4. import java.util.function.DoublePredicate;
  5.  
  6. public class ToyShop {
  7. public static void main(String[] args) {
  8. Scanner scanner = new Scanner(System.in);
  9. double holidayPrice = Double.parseDouble(scanner.nextLine());
  10. double puzzle = Integer.parseInt(scanner.nextLine());
  11. double dolls = Integer.parseInt(scanner.nextLine());
  12. double bears = Integer.parseInt(scanner.nextLine());
  13. double minions = Integer.parseInt(scanner.nextLine());
  14. double trucks = Integer.parseInt(scanner.nextLine());
  15.  
  16. double sumToys = puzzle * 2.60 + dolls * 3 + bears * 4.10 + minions * 8.20 + trucks * 2;
  17. double numToys = puzzle + dolls + bears + minions + trucks;;
  18.  
  19. if (numToys >= 50){
  20. sumToys -= sumToys * 0.25;
  21. }
  22. sumToys -= sumToys * 0.1;
  23. if (sumToys >= holidayPrice){
  24. System.out.printf("Yes! %.2f lv left.",sumToys - holidayPrice );
  25. }else {
  26. System.out.printf("Not enough money! %.2f lv needed.", holidayPrice - sumToys);
  27. }
  28.  
  29.  
  30. }
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement