bobski1617

Untitled

Sep 10th, 2021
177
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.35 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class passwordGuess {
  4. public static void main(String[] args) {
  5. Scanner scanner = new Scanner(System.in);
  6.  
  7. double tripPrice = Double.parseDouble(scanner.nextLine());
  8. int puzzle = Integer.parseInt(scanner.nextLine());
  9. int doll = Integer.parseInt(scanner.nextLine());
  10. int bear = Integer.parseInt(scanner.nextLine());
  11. int minion = Integer.parseInt(scanner.nextLine());
  12. int track = Integer.parseInt(scanner.nextLine());
  13.  
  14. double puzzlePrice = 2.6 * puzzle;
  15. double dollPrice = 3 * doll;
  16. double bearPrice = 4.1 * bear;
  17. double minionPrice = 8.2 * minion;
  18. double trackPrice = 2 * track;
  19.  
  20. double price = puzzlePrice + dollPrice + bearPrice + minionPrice + trackPrice;
  21. int totalToys = puzzle + doll + bear + minion + track;
  22. double discount = 0;
  23.  
  24. if (totalToys > 50) {
  25. discount = price * 0.25;
  26. }
  27.  
  28. double rent = (price - discount) * 0.1;
  29.  
  30. double finalPrice = price - discount - rent;
  31.  
  32. double moneyLeft = finalPrice - tripPrice;
  33.  
  34. if (moneyLeft>=0){
  35. System.out.printf("Yes! %.2f lv left.", moneyLeft);
  36. } else {
  37. System.out.printf("Not enough money! %.2f lv needed.", Math.abs(moneyLeft));
  38. }
  39.  
  40. }
  41. }
  42.  
Advertisement
Add Comment
Please, Sign In to add comment