Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.sql.SQLOutput;
- import java.text.DecimalFormat;
- import java.util.Scanner;
- public class ToyStore {
- 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 dolls = Integer.parseInt(scanner.nextLine());
- int bears = Integer.parseInt(scanner.nextLine());
- int minions = Integer.parseInt(scanner.nextLine());
- int trucks = Integer.parseInt(scanner.nextLine());
- int totalNumberToys = puzzles + dolls + bears + minions + trucks;
- double toySum = 0.90 * ((puzzles * 2.60) + (dolls * 3.00) + (bears * 4.10)
- + (minions * 8.20) + (trucks * 2.00));
- double toySum50 = 0.75 * toySum;
- double profit = toySum - TripPrice;
- double profit1 = toySum50 - TripPrice;
- DecimalFormat f = new DecimalFormat("##.00");
- if (totalNumberToys >= 50 && toySum50 > TripPrice ) {
- System.out.println("Yes! " + f.format(profit1) + " " + "lv left.");
- }
- else if (totalNumberToys < 50 && toySum > TripPrice) {
- System.out.println("Yes! " + f.format(profit) + " " + "lv left.");
- }
- if (totalNumberToys >= 50 && toySum50 < TripPrice) {
- System.out.println("Not enough money! " + f.format(TripPrice - toySum50) + " " + "lv needed.");
- }
- else if (totalNumberToys < 50 && toySum < TripPrice) {
- System.out.println("Not enough money! " + f.format(TripPrice - toySum) + " " + "lv needed.");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment