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 tripPrice = Double.parseDouble(scanner.nextLine());
- int puzzles = Integer.parseInt(scanner.nextLine());
- int barbieDolls = Integer.parseInt(scanner.nextLine());
- int bears = Integer.parseInt(scanner.nextLine());
- int minions = Integer.parseInt(scanner.nextLine());
- int trucks = Integer.parseInt(scanner.nextLine());
- double totalPuzzlesPrice= 2.60* puzzles;
- double totalBarbiePrice = 3.0*barbieDolls ;
- double totalBearsPrice = 4.10*bears;
- double totalMinionsPrice = 8.20*minions;
- double totalTrucksPrice = 2.0*trucks;
- double total= totalPuzzlesPrice+totalBarbiePrice+totalBearsPrice+totalMinionsPrice+totalTrucksPrice;
- double counter=puzzles+barbieDolls+bears+minions+trucks;
- if (counter>=50)
- {
- total=total*0.75;
- }
- double finalProfit=total*0.9;
- if (finalProfit>=tripPrice)
- {
- double diff=finalProfit-tripPrice;
- System.out.printf("Yes! %.2f lv left.",diff);
- }
- else
- {
- double difference=tripPrice-finalProfit;
- System.out.printf("Not enough money! %.2f lv needed.",difference);
- }
- }
- }
Add Comment
Please, Sign In to add comment