Helena12

ToyStore (SoftUni Exam)

Oct 19th, 2018
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.65 KB | None | 0 0
  1. import java.sql.SQLOutput;
  2. import java.text.DecimalFormat;
  3. import java.util.Scanner;
  4.  
  5. public class ToyStore {
  6.     public static void main(String[] args) {
  7.         Scanner scanner = new Scanner(System.in);
  8.         double TripPrice = Double.parseDouble(scanner.nextLine());
  9.         int puzzles = Integer.parseInt(scanner.nextLine());
  10.         int dolls = Integer.parseInt(scanner.nextLine());
  11.         int bears = Integer.parseInt(scanner.nextLine());
  12.         int minions = Integer.parseInt(scanner.nextLine());
  13.         int trucks = Integer.parseInt(scanner.nextLine());
  14.         int totalNumberToys = puzzles + dolls + bears + minions + trucks;
  15.         double toySum = 0.90 * ((puzzles * 2.60) + (dolls * 3.00) + (bears * 4.10)
  16.                 + (minions * 8.20) + (trucks * 2.00));
  17.         double toySum50 = 0.75 * toySum;
  18.         double profit = toySum - TripPrice;
  19.         double profit1 = toySum50 - TripPrice;
  20.         DecimalFormat f = new DecimalFormat("##.00");
  21.  
  22.         if (totalNumberToys >= 50 && toySum50 > TripPrice ) {
  23.                 System.out.println("Yes! " + f.format(profit1) + " " + "lv left.");
  24.             }
  25.         else if (totalNumberToys < 50 && toySum > TripPrice) {
  26.             System.out.println("Yes! " + f.format(profit) + " " + "lv left.");
  27.         }
  28.         if (totalNumberToys >= 50 && toySum50 < TripPrice) {
  29.                 System.out.println("Not enough money! " + f.format(TripPrice - toySum50) + " " + "lv needed.");
  30.             }
  31.         else if (totalNumberToys < 50 && toySum < TripPrice) {
  32.             System.out.println("Not enough money! " + f.format(TripPrice - toySum) + " " + "lv needed.");
  33.         }
  34.         }
  35.     }
Advertisement
Add Comment
Please, Sign In to add comment