Advertisement
i_graurov

Hello France

Feb 28th, 2020
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.94 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class helloFrance {
  4.     public static void main(String[] args) {
  5.         Scanner scanner = new Scanner(System.in);
  6.         String input = scanner.nextLine();
  7.         double budget = Double.parseDouble(scanner.nextLine());
  8.         double BudgetInBegining = budget;
  9.         double totalProfit = 0;
  10.         String[] offers = input.split("\\|");
  11.         String[] prices = new String[offers.length * 2];
  12.         for (int i = 0; i < offers.length; i++) {
  13.             prices = offers[i].split("->");
  14.             double price = Double.parseDouble(prices[1]);
  15.             double profit = (price * 40) / 100;
  16.  
  17.             switch (prices[0]) {
  18.                 case "Clothes": {
  19.                     if (price <= 50 && budget > price) {
  20.                         budget = budget - price;
  21.                         System.out.printf("%.2f ", price + profit);
  22.                         totalProfit += profit;
  23.                     }
  24.                 }
  25.                 break;
  26.                 case "Shoes": {
  27.                     if (price <= 35 && budget > price) {
  28.                         budget = budget - price;
  29.                         System.out.printf("%.2f ", price + profit);
  30.                         totalProfit += profit;
  31.  
  32.                     }
  33.                 }
  34.                 break;
  35.                 case "Accessories": {
  36.                     if (price <= 20.5 && budget > price) {
  37.                         budget = budget - price;
  38.                         System.out.printf("%.2f ", price + profit);
  39.                         totalProfit += profit;
  40.                     }
  41.                 }
  42.                 break;
  43.  
  44.  
  45.             }
  46.         }
  47.         System.out.println();
  48.         System.out.printf("Profit: %.2f%n", totalProfit);
  49.  
  50.         if (BudgetInBegining + totalProfit >= 150) {
  51.             System.out.println("Hello, France!");
  52.         } else {
  53.             System.out.println("Time to go.");
  54.         }
  55.  
  56.  
  57.     }
  58. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement