Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class toyStore {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- double puzzle = 2.60;
- double talkingDoll = 3;
- double teddyBear = 4.10;
- double minion = 8.20;
- double truck = 2.00;
- double priceOfVacation = Double.parseDouble(scanner.nextLine());
- double numberOfPuzzles = Double.parseDouble(scanner.nextLine());
- double numberOfTalkingDolls = Double.parseDouble(scanner.nextLine());
- double numberOfTeddyBears = Double.parseDouble(scanner.nextLine());
- double numberOfMinions = Double.parseDouble(scanner.nextLine());
- double numberOfTrucks = Double.parseDouble(scanner.nextLine());
- double totalToysOrdered = numberOfMinions + numberOfPuzzles + numberOfTalkingDolls + numberOfTeddyBears + numberOfTrucks;
- double totalEarnings = (puzzle * numberOfPuzzles) + (talkingDoll * numberOfTalkingDolls) + (teddyBear * numberOfTeddyBears) + (minion * numberOfMinions) + (truck * numberOfTrucks);
- if (totalToysOrdered >= 50) {
- double discount = totalEarnings * 0.25;
- double discountedPrice = totalEarnings - discount;
- double rentPrice = discountedPrice * 0.10;
- double revenue = discountedPrice - rentPrice;
- if (revenue >= priceOfVacation) {
- System.out.printf("Yes! %.2f lv left.", revenue - priceOfVacation);
- } else if (revenue < priceOfVacation) {
- double priceWhenFail = priceOfVacation - revenue;
- System.out.printf("Not enough money! %.2f lv needed.", priceWhenFail);
- }
- } else if (totalToysOrdered < 50) {
- double rentPrice = totalEarnings * 0.10;
- double revenue = totalEarnings - rentPrice;
- if(revenue >= priceOfVacation){
- System.out.printf("Yes! %.2f lv left.", revenue - priceOfVacation);
- }else if(revenue < priceOfVacation){
- double priceWhenFail = priceOfVacation - revenue;
- System.out.printf("Not enough money! %.2f lv needed.", priceWhenFail);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement