Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.company;
- import java.util.ArrayList;
- import java.util.Collections;
- import java.util.List;
- import java.util.Scanner;
- public class Main {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- String[] line = scanner.nextLine().split("\\|+");
- double budget = Double.parseDouble(scanner.nextLine());
- List<Double> newPrices = new ArrayList<>();
- double spentMoney = 0;
- double budgetAfterSelling = 0;
- double sumNewPrices = 0;
- for (int i = 0; i < line.length; i++) {
- String[] item = line[i].split("->");
- String type = item[0];
- double price = Double.parseDouble(item[1]);
- if (type.equals("Clothes")) {
- if (price <= 50.00) {
- if (budget >= price) {
- budget -= price;
- spentMoney += price;
- double newPrice = 0.4 * price + price;
- sumNewPrices += newPrice;
- newPrices.add(newPrice);
- }
- }
- } else if (type.equals("Shoes")) {
- if (price <= 35) {
- if (budget >= price) {
- budget -= price;
- spentMoney += price;
- double newPrice = 0.4 * price + price;
- sumNewPrices += newPrice;
- newPrices.add(newPrice);
- }
- }
- } else if (type.equals("Accessories")) {
- if (price <= 20.50) {
- if (budget >= price) {
- budget -= price;
- spentMoney += price;
- double newPrice = 0.4 * price + price;
- sumNewPrices += newPrice;
- newPrices.add(newPrice);
- }
- }
- }
- }
- double profit = spentMoney * 0.4;
- for (int i = 0; i < newPrices.size(); i++) {
- System.out.printf("%.2f ", newPrices.get(i));
- }
- System.out.println();
- System.out.printf("Profit: %.2f", profit);
- System.out.println();
- budgetAfterSelling = budget + sumNewPrices;
- if (budgetAfterSelling >= 150.0) {
- System.out.println("Hello, France!");
- } else {
- System.out.println("Time to go.");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement