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 scan = new Scanner(System.in);
- double tripPrice = Double.parseDouble(scan.nextLine());
- int puzzles = Integer.parseInt(scan.nextLine());
- int dolls = Integer.parseInt(scan.nextLine());
- int bears = Integer.parseInt(scan.nextLine());
- int minions = Integer.parseInt(scan.nextLine());
- int trucks = Integer.parseInt(scan.nextLine());
- double puzzlePrice = 2.6;
- double dollPrice = 3;
- double teddyBearPrice = 4.10;
- double minionPrice = 8.2;
- double truckPrice = 2;
- int toys = puzzles + dolls + bears + minions + trucks;
- double totalPrice = puzzles * puzzlePrice + dollPrice * dolls + teddyBearPrice * bears + minionPrice * minions + truckPrice * trucks;
- if (toys >= 50) {
- totalPrice = totalPrice - totalPrice * 0.25;
- }
- totalPrice = totalPrice - totalPrice * 0.10;
- if (totalPrice >= tripPrice) {
- totalPrice -= tripPrice;
- System.out.printf("Yes! %.2f lv left.", totalPrice);
- } else {
- totalPrice -= tripPrice;
- System.out.printf("Not enough money! %.2f lv needed.", Math.abs(totalPrice));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement