Advertisement
Alexander_B

Clever Lily

Feb 16th, 2019
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.70 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace DomashnoCleverLili
  8. {
  9. class Program
  10. {
  11. static void Main(string[] args)
  12. {
  13. // get input --> int age, double washinMashinePrice, double oneToyPrice
  14.  
  15. int age = int.Parse(Console.ReadLine());
  16. double washingMashinePrice = double.Parse(Console.ReadLine());
  17. double oneToyPrice = double.Parse(Console.ReadLine());
  18.  
  19.  
  20. // determen variables --> accumulate toy, moneySum
  21.  
  22. int accumulateToyNumber = 0;
  23.  
  24. double moneySum = 0;
  25.  
  26.  
  27. // how many toys
  28.  
  29. for (int i = 0; i <= age; i++)
  30. {
  31. if (i % 2 == 1)
  32. {
  33. accumulateToyNumber++;
  34. }
  35. }
  36.  
  37.  
  38. // how much money
  39.  
  40. for (int i = 1; i <= age; i++)
  41. {
  42.  
  43. if (i % 2 == 0)
  44. {
  45. moneySum += i / 2 * 10;
  46. moneySum--;
  47. }
  48. }
  49.  
  50. // all money and are they enough
  51.  
  52. double allMoneySum = moneySum + (oneToyPrice * accumulateToyNumber);
  53.  
  54. double printEnough = allMoneySum - washingMashinePrice;
  55.  
  56. double printNotEnough = washingMashinePrice - allMoneySum;
  57.  
  58. // print result
  59.  
  60. if (allMoneySum >= washingMashinePrice)
  61. {
  62. Console.WriteLine($"Yes! {printEnough:f2}");
  63. }
  64. else
  65. {
  66. Console.WriteLine($"No! {printNotEnough:f2}");
  67. }
  68. }
  69. }
  70. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement