Advertisement
Guest User

02. Hello, France (100/100 SoftUni)

a guest
Mar 15th, 2019
482
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.05 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4.  
  5. namespace HelloFrance_try2_
  6. {
  7.     class Program
  8.     {
  9.         static void Main(string[] args)
  10.         {
  11.             List<string> input = Console.ReadLine().Split('|').ToList();
  12.             double budget = double.Parse(Console.ReadLine());
  13.  
  14.             List<double> prices = new List<double>();
  15.             double profit = 0.00;
  16.  
  17.  
  18.  
  19.             for (int i = 0; i < input.Count; i++)
  20.             {
  21.                 string itemType = input[i].Split("->")[0];
  22.                 double price = double.Parse(input[i].Split("->").Last());
  23.  
  24.                 if (itemType == "Clothes" && price <= 50.00 && budget - price >= 0) // 3 checks = 1: Type, 2: Price, 3: Available Money
  25.                 {
  26.                     budget -= price;
  27.                     profit += price * 0.40;
  28.                     prices.Add(price * 1.40);
  29.                 }
  30.                 else if (itemType == "Shoes" && price <= 35.00 && budget - price >= 0) // 3 checks = 1: Type, 2: Price, 3: Available Money
  31.                 {
  32.                     budget -= price;
  33.                     profit += price * 0.40;
  34.                     prices.Add(price * 1.40);
  35.                 }
  36.                 else if (itemType == "Accessories" && price <= 20.50 && budget - price >= 0) // 3 checks = 1: Type, 2: Price, 3: Available Money
  37.                 {
  38.                     budget -= price;
  39.                     profit += price * 0.40;
  40.                     prices.Add(price * 1.40);
  41.                 }
  42.             }
  43.  
  44.             //Console.WriteLine(string.Join(' ', prices));
  45.             foreach (var item in prices)
  46.             {
  47.  
  48.                 Console.Write($"{item:F2} ");
  49.  
  50.             }
  51.  
  52.             Console.WriteLine();
  53.  
  54.             Console.WriteLine($"Profit: {profit:F2}");
  55.  
  56.             if (budget + prices.Sum() >= 150.00)
  57.             {
  58.                 Console.WriteLine("Hello, France!");
  59.             }
  60.             else
  61.             {
  62.                 Console.WriteLine("Time to go.");
  63.             }
  64.  
  65.         }
  66.     }
  67. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement