Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class P10ToyShop {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- double PuzzlePrice = 2.60;
- double DollsPrice = 3;
- double BearsPrice = 4.10;
- double MinionsPrice = 8.20;
- double LorryPrice = 2;
- double TripPrice = Double.parseDouble(scanner.nextLine());
- int PuzzlesCount = Integer.parseInt(scanner.nextLine());
- int DollsCount = Integer.parseInt(scanner.nextLine());
- int BearsCount = Integer.parseInt(scanner.nextLine());
- int MinionsCount = Integer.parseInt(scanner.nextLine());
- int LorryCount = Integer.parseInt(scanner.nextLine());
- double PuzzlesTotalPice = PuzzlePrice * PuzzlesCount;
- double DollsTotalPrice = DollsPrice * DollsCount;
- double BearsTotalPrice = BearsPrice * BearsCount;
- double MinionsTotalPrice = MinionsPrice * MinionsCount;
- double LorryTotalPrice = LorryPrice * LorryCount;
- int TotalToysCount = PuzzlesCount + DollsCount + BearsCount + MinionsCount + LorryCount;
- double TotalToysPrice = PuzzlesTotalPice + DollsTotalPrice + BearsTotalPrice + MinionsTotalPrice + LorryTotalPrice;
- if(TotalToysCount >= 50){
- TotalToysPrice = TotalToysPrice * 0.75;
- }
- TotalToysPrice = TotalToysPrice * 0.9;
- double diff = TotalToysPrice - TripPrice;
- if (diff < 0) {
- System.out.printf("Not enough money! %.2f lv needed.", Math.abs(diff));
- } else {
- System.out.printf("Yes! %.2f lv left.", diff); }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment