Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class helloFrance {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- String input = scanner.nextLine();
- double budget = Double.parseDouble(scanner.nextLine());
- double BudgetInBegining = budget;
- double totalProfit = 0;
- String[] offers = input.split("\\|");
- String[] prices = new String[offers.length * 2];
- for (int i = 0; i < offers.length; i++) {
- prices = offers[i].split("->");
- double price = Double.parseDouble(prices[1]);
- double profit = (price * 40) / 100;
- switch (prices[0]) {
- case "Clothes": {
- if (price <= 50 && budget > price) {
- budget = budget - price;
- System.out.printf("%.2f ", price + profit);
- totalProfit += profit;
- }
- }
- break;
- case "Shoes": {
- if (price <= 35 && budget > price) {
- budget = budget - price;
- System.out.printf("%.2f ", price + profit);
- totalProfit += profit;
- }
- }
- break;
- case "Accessories": {
- if (price <= 20.5 && budget > price) {
- budget = budget - price;
- System.out.printf("%.2f ", price + profit);
- totalProfit += profit;
- }
- }
- break;
- }
- }
- System.out.println();
- System.out.printf("Profit: %.2f%n", totalProfit);
- if (BudgetInBegining + totalProfit >= 150) {
- System.out.println("Hello, France!");
- } else {
- System.out.println("Time to go.");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement