Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package RealMID_10_03_19;
- import java.util.ArrayList;
- import java.util.List;
- import java.util.Scanner;
- public class _02_Task {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- String input = scanner.nextLine();
- double budget = Double.parseDouble(scanner.nextLine());
- String[] line = input.split("\\|");
- List<Double> buy = new ArrayList<>();
- double maxClothes = 50.00;
- double maxShoes = 35.00;
- double maxAcc = 20.50;
- double initialSum = 0;
- for (int i = 0; i < line.length; i++) {
- String[] elem = line[i].split("->");
- double price = Double.parseDouble(elem[1]);
- if (budget < price) {
- continue;
- }
- switch (elem[0]) {
- case "Clothes":
- if (price <= maxClothes) {
- initialSum += price;
- budget -= Double.parseDouble(elem[1]);
- price += Double.parseDouble(elem[1]) * 0.4;
- buy.add(price);
- }
- break;
- case "Shoes":
- if (price <= maxShoes) {
- initialSum += price;
- budget -= Double.parseDouble(elem[1]);
- price += Double.parseDouble(elem[1]) * 0.4;
- buy.add(price);
- }
- break;
- case "Accessories":
- if (price <= maxAcc) {
- initialSum += price;
- budget -= Double.parseDouble(elem[1]);
- price += Double.parseDouble(elem[1]) * 0.4;
- buy.add(price);
- }
- break;
- }
- }
- double sum = 0;
- for (Double price : buy) {
- sum += price;
- System.out.printf("%.2f", price);
- System.out.print(" ");
- }
- System.out.println();
- System.out.print("Profit: ");
- double profit = sum - initialSum;
- System.out.printf("%.2f%n", profit);
- if (sum + budget>= 150.00) {
- System.out.println("Hello, France!");
- } else {
- System.out.println("Time to go.");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement