Advertisement
fr3s7ed

Untitled

May 27th, 2018
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.87 KB | None | 0 0
  1. using System;
  2. using System.Linq;
  3. using System.Collections.Generic;
  4.  
  5. namespace ObjectsAndClasses
  6. {
  7. class Program
  8. {
  9. //ASDA% 50
  10. //DaS@!%$$ 10
  11. //$$ 10
  12. static void Main(string[] args)
  13. {
  14. int[] prices = Console.ReadLine().Split().Select(int.Parse).ToArray();
  15.  
  16. int goldPrice = prices[1];
  17. int jewelsPrice = prices[0];
  18.  
  19. long goldIncome = 0;
  20. long jewelsIncome = 0;
  21.  
  22. long goldExpenses = 0;
  23. long jewelsExpense = 0;
  24.  
  25. string input;
  26.  
  27. while ((input = Console.ReadLine()) != "Jail Time")
  28. {
  29. string[] tokens = input.Split().ToArray();
  30.  
  31. char[] data = tokens[0].ToCharArray();
  32. long expense = long.Parse(tokens[1]);
  33.  
  34. for (int i = 0; i < data.Length; i++)
  35. {
  36. if(data[i] == '$')
  37. {
  38. goldIncome += goldPrice;
  39. goldExpenses += expense;
  40. }
  41.  
  42. if(data[i] == '%')
  43. {
  44. jewelsIncome += jewelsPrice;
  45. jewelsExpense += expense;
  46. }
  47. }
  48. }
  49.  
  50.  
  51. long totalIncome = goldIncome + jewelsIncome;
  52. long totalExpense = goldExpenses + jewelsExpense;
  53.  
  54. if(totalIncome >= totalExpense)
  55. {
  56. long result = totalIncome - totalExpense;
  57. Console.WriteLine("Heists will continue. Total earnings: {0}.", result);
  58. }
  59. else
  60. {
  61. long result = totalExpense - totalIncome;
  62. Console.WriteLine("Have to find another job. Lost: {0}.", result);
  63. }
  64. }
  65.  
  66. }
  67. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement