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);
- // READ:
- //1. price of excursion -> double
- //2. number of puzzles -> int
- //3. number of dolls -> int
- //4. number of bears -> int
- //5. number of minions -> int
- //6. number of trucks -> int
- double excursionPrice = Double.parseDouble(scanner.nextLine());
- int nOfPuzzles = Integer.parseInt(scanner.nextLine());
- int nOfDolls = Integer.parseInt(scanner.nextLine());
- int nOfBears = Integer.parseInt(scanner.nextLine());
- int nOfMinions = Integer.parseInt(scanner.nextLine());
- int nOfTrucks = Integer.parseInt(scanner.nextLine());
- // Calculate price of an order - > number of toys * price (given)
- double totalPricePuzzles = nOfPuzzles * 2.60;
- int totalPriceDolls = nOfDolls * 3;
- double totalPriceBears = nOfBears * 4.10;
- double totalPriceMinions = nOfMinions * 8.20;
- int totalPriceTrucks = nOfTrucks * 2;
- double totalNOfToys = nOfPuzzles + nOfDolls + nOfBears + nOfMinions + nOfTrucks;
- double totalPriceOfOrder = totalPricePuzzles + totalPriceDolls + totalPriceBears + totalPriceMinions + totalPriceTrucks;
- double afterRent = totalPriceOfOrder * 0.9;
- if (totalNOfToys >= 50) {
- // calculate total after discount = Tot Price Of order - 25% discount
- double afterDiscount = totalPriceOfOrder * 0.75;
- // Calculate total net after deducting for rent
- double afterRent1 = afterDiscount * 0.9;
- //
- if (excursionPrice < afterRent1) {
- System.out.printf("Yes! %.2f lv left.", afterRent1 - excursionPrice );
- } else {
- System.out.printf("Not enough money! %.2f lv needed.", excursionPrice -afterRent);
- }
- }
- else if (totalNOfToys < 50) {
- } if (excursionPrice < afterRent ) {
- System.out.printf("Yes! %.2f lv left.", afterRent - excursionPrice );
- } else {
- System.out.printf("Not enough money! %.2f lv needed.", excursionPrice - afterRent);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement