Guest User

Untitled

a guest
Apr 26th, 2018
168
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.97 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 _3.Solar_System
  8. {
  9. class Program
  10. {
  11. static void Main(string[] args)
  12. {
  13. string planetToVisit = Console.ReadLine();
  14. byte daysSpent = byte.Parse(Console.ReadLine());
  15.  
  16. Dictionary<string, double> distance = new Dictionary<string, double>()
  17. {
  18. { "Mercury", 0.61 },
  19. {"Venus", 0.28 },
  20. { "Mars",0.52},
  21. {"Jupiter", 4.2},
  22. {"Saturn", 8.52 },
  23. {"Uranus", 18.21 },
  24. {"Neptune", 29.09 }
  25. };
  26. Dictionary<string, int> allowedDays = new Dictionary<string, int>()
  27. {
  28. { "Mercury", 7 },
  29. {"Venus", 14 },
  30. { "Mars",20},
  31. {"Jupiter", 5},
  32. {"Saturn", 3 },
  33. {"Uranus", 3 },
  34. {"Neptune", 2 }
  35. };
  36. double value;
  37. int value1;
  38.  
  39. if (!distance.ContainsKey(planetToVisit))
  40. {
  41. Console.WriteLine("Invalid planet name!");
  42. return;
  43. }
  44.  
  45.  
  46. allowedDays.TryGetValue(planetToVisit, out value1);
  47.  
  48. if (daysSpent > value1)
  49. {
  50. Console.WriteLine("Invalid number of days!");
  51. return;
  52. }
  53.  
  54.  
  55. if(distance.ContainsKey(planetToVisit))
  56. {
  57. distance.TryGetValue(planetToVisit, out value);
  58.  
  59. double totaldistance = 2 * value;
  60. double days = 2 * (226 * value) + daysSpent;
  61. Console.WriteLine($"Distance: {totaldistance:f2}");
  62. Console.WriteLine($"Total number of days: {days:f2}");
  63. }
  64.  
  65.  
  66. }
  67. }
  68. }
Advertisement
Add Comment
Please, Sign In to add comment