Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class passwordGuess {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- double tripPrice = Double.parseDouble(scanner.nextLine());
- int puzzle = Integer.parseInt(scanner.nextLine());
- int doll = Integer.parseInt(scanner.nextLine());
- int bear = Integer.parseInt(scanner.nextLine());
- int minion = Integer.parseInt(scanner.nextLine());
- int track = Integer.parseInt(scanner.nextLine());
- double puzzlePrice = 2.6 * puzzle;
- double dollPrice = 3 * doll;
- double bearPrice = 4.1 * bear;
- double minionPrice = 8.2 * minion;
- double trackPrice = 2 * track;
- double price = puzzlePrice + dollPrice + bearPrice + minionPrice + trackPrice;
- int totalToys = puzzle + doll + bear + minion + track;
- double discount = 0;
- if (totalToys > 50) {
- discount = price * 0.25;
- }
- double rent = (price - discount) * 0.1;
- double finalPrice = price - discount - rent;
- double moneyLeft = finalPrice - tripPrice;
- if (moneyLeft>=0){
- System.out.printf("Yes! %.2f lv left.", moneyLeft);
- } else {
- System.out.printf("Not enough money! %.2f lv needed.", Math.abs(moneyLeft));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment