Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class ToyShop {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- double priceTrip = Double.parseDouble(scanner.nextLine());
- int numPuzzle = Integer.parseInt(scanner.nextLine());
- int numDolls = Integer.parseInt(scanner.nextLine());
- int numBears = Integer.parseInt(scanner.nextLine());
- int numMinion = Integer.parseInt(scanner.nextLine());
- int numTruck = Integer.parseInt(scanner.nextLine());
- double allToys = numPuzzle + numDolls + numBears + numMinion + numTruck;
- double allSum = (numPuzzle * 2.60) + (numDolls * 3) + ( numBears * 4.10) + (numMinion * 8.20) + (numTruck * 2);
- if ( allToys >= 50 ){
- allSum = allSum * 0.75;
- }
- allSum = allSum * 0.90;
- if ( allSum >= priceTrip) {
- System.out.printf("Yes! %.2f lv left.", allSum - priceTrip);
- }else {
- System.out.printf("Not enough money! %.2f lv needed.", priceTrip - allSum);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement