mattnguyen

My Retake Mid Exam 17/08/2021 Problem 1

Aug 17th, 2021
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.82 KB | None | 0 0
  1. using System;
  2. using System.Linq;
  3. using System.Numerics;
  4. using System.Text;
  5. using System.Collections.Generic;
  6. using System.ComponentModel;
  7. using System.Reflection.Metadata.Ecma335;
  8. using System.Runtime.ExceptionServices;
  9. using System.Threading;
  10. using System.Text.RegularExpressions;
  11.  
  12. namespace ConsoleApp24
  13. {
  14. class Program
  15. {
  16. static void Main(string[] args)
  17. {
  18. int days = int.Parse(Console.ReadLine());
  19. int playerCount = int.Parse(Console.ReadLine());
  20. double HP = double.Parse(Console.ReadLine());
  21. double waterPerPerson = double.Parse(Console.ReadLine());
  22. double foodPerPerson = double.Parse(Console.ReadLine());
  23. double totalWater = waterPerPerson * playerCount*days;
  24. double totalFood = foodPerPerson * playerCount*days;
  25.  
  26.  
  27. for (int i = 1; i <= days; i++)
  28. {
  29. double HPloss = double.Parse(Console.ReadLine());
  30.  
  31. HP -= HPloss;
  32.  
  33. if (HP <= 0)
  34. {
  35. break;
  36. }
  37.  
  38. if (i % 2 == 0 && i >= 2)
  39. {
  40. HP *= 1.05;
  41. totalWater *= 0.7;
  42. }
  43.  
  44. if (i % 3 == 0 && i >= 3)
  45. {
  46. totalFood -= ((double)totalFood / playerCount);
  47. HP *= 1.1;
  48. }
  49. }
  50.  
  51. if (HP > 0)
  52. {
  53. Console.WriteLine($"You are ready for the quest. You will be left with - {HP:f2} energy!");
  54. }
  55. else
  56. {
  57. Console.WriteLine($"You will run out of energy. You will be left with {totalFood:f2} food and {totalWater:f2} water.");
  58. }
  59. }
  60. }
  61. }
Advertisement
Add Comment
Please, Sign In to add comment