Advertisement
Guest User

Untitled

a guest
Mar 12th, 2019
170
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 3.91 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4.  
  5. namespace p02
  6. {
  7.     class Program
  8.     {
  9.         static void Main(string[] args)
  10.         {
  11.             string input = Console.ReadLine();
  12.  
  13.             decimal budget = decimal.Parse(Console.ReadLine());
  14.  
  15.             decimal clothesMAXPrice = 50.00m;
  16.             decimal shoesMAXPrice = 35.00m;
  17.             decimal accessoriesMAXPrice = 20.50m;
  18.             string command = string.Empty;
  19.             int start = 0;
  20.             decimal increasedPrice = 0.00m;
  21.  
  22.             decimal profit = 0.00m;
  23.             decimal currentProfit = 0.00m;
  24.             decimal newBudget = 0.00m;
  25.  
  26.             List<string> tokens = input.Split("|").ToList();
  27.  
  28.             List<decimal> newPrices = new List<decimal>();
  29.  
  30.             for (int i = start; i < tokens.Count; i++)
  31.             {
  32.                 command = tokens[i];
  33.                 List<string> readyList = command.Split("->").ToList();
  34.  
  35.                 string item = readyList[0];
  36.                 decimal itemPrice = decimal.Parse(readyList[1]);
  37.  
  38.                 if (item == "Clothes")
  39.                 {
  40.                     if (budget < itemPrice)
  41.                     {
  42.                         continue;
  43.                     }
  44.                     else if (itemPrice > clothesMAXPrice)
  45.                     {
  46.                        
  47.                     }
  48.                     else
  49.                     {
  50.                         budget = budget - itemPrice;
  51.                         increasedPrice = (itemPrice * 0.4m) + itemPrice;
  52.                         currentProfit = increasedPrice - itemPrice;
  53.                         profit += currentProfit;
  54.                         increasedPrice = Math.Round(increasedPrice, 2);
  55.                         newPrices.Add(increasedPrice);
  56.                     }
  57.                 }
  58.  
  59.                 if (item == "Shoes")
  60.                 {
  61.                     if (budget < itemPrice)
  62.                     {
  63.                         continue;
  64.                     }
  65.                     else if (itemPrice > shoesMAXPrice)
  66.                     {
  67.                        
  68.                     }
  69.                     else
  70.                     {
  71.                         budget = budget - itemPrice;
  72.                         increasedPrice = (itemPrice * 0.4m) + itemPrice;
  73.                         currentProfit = increasedPrice - itemPrice;
  74.                         profit += currentProfit;
  75.                         increasedPrice = Math.Round(increasedPrice, 2);
  76.                         newPrices.Add(increasedPrice);
  77.                     }
  78.                 }
  79.                 if (item == "Accessories")
  80.                 {
  81.                     if (budget < itemPrice)
  82.                     {
  83.                         continue;
  84.                     }
  85.                     else if (itemPrice > accessoriesMAXPrice)
  86.                     {
  87.                        
  88.                     }
  89.                     else
  90.                     {
  91.                         budget = budget - itemPrice;
  92.                         increasedPrice = (itemPrice * 0.4m) + itemPrice;
  93.                         currentProfit = increasedPrice - itemPrice;
  94.                         profit += currentProfit;
  95.                         increasedPrice = Math.Round(increasedPrice, 2);
  96.                         newPrices.Add(increasedPrice);
  97.                     }
  98.                 }
  99.             }
  100.             newBudget = budget + newPrices.Sum();
  101.  
  102.             if (newBudget >= 150)
  103.             {
  104.                 Console.WriteLine(string.Join(" ", newPrices));
  105.                 Console.WriteLine($"Profit: {profit:f2}");
  106.                 Console.WriteLine("Hello, France!");
  107.             }
  108.             else
  109.             {
  110.                 Console.WriteLine(string.Join(" ", newPrices));
  111.                 Console.WriteLine($"Profit: {profit:f2}");
  112.                 Console.WriteLine("Time to go.");
  113.             }
  114.         }
  115.     }
  116. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement