Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- class Program
- {
- static void Main(string[] args)
- {
- string nameOfPlanet = Console.ReadLine();
- int daysOfStaying = int.Parse(Console.ReadLine());
- double distance = 0;
- double calculate = 0;
- bool validPlanet = true;
- bool validNumberOfDays = true;
- if (nameOfPlanet == "Mercury")
- {
- if (daysOfStaying <= 7)
- {
- distance = 0.61 * 2;
- calculate = 2 * (226 * 0.61) + daysOfStaying;
- }
- else
- {
- validNumberOfDays = false;
- }
- }
- else if (nameOfPlanet == "Venus")
- {
- if (daysOfStaying <= 14)
- {
- distance = 0.28 * 2;
- calculate = 2 * (226 * 0.28) + daysOfStaying;
- }
- else
- {
- validNumberOfDays = false;
- }
- }
- else if (nameOfPlanet == "Mars")
- {
- if (daysOfStaying <= 20)
- {
- distance = 0.52 * 2;
- calculate = 2 * (226 * 0.52) + daysOfStaying;
- }
- else
- {
- validNumberOfDays = false;
- }
- }
- else if (nameOfPlanet == "Jupiter")
- {
- if (daysOfStaying <= 5)
- {
- distance = 4.2 * 2;
- calculate = 2 * (226 * 4.2) + daysOfStaying;
- }
- else
- {
- validNumberOfDays = false;
- }
- }
- else if (nameOfPlanet == "Saturn")
- {
- if (daysOfStaying <= 3)
- {
- distance = 8.52 * 2;
- calculate = 2 * (226 * 8.52) + daysOfStaying;
- }
- else
- {
- validNumberOfDays = false;
- }
- }
- else if (nameOfPlanet == "Uranus")
- {
- if (daysOfStaying <= 3)
- {
- distance = 2 * 18.21;
- calculate = 2 * (226 * 18.21) + daysOfStaying;
- }
- else
- {
- validNumberOfDays = false;
- }
- }
- else if (nameOfPlanet == "Neptune")
- {
- if (daysOfStaying <= 2)
- {
- distance = 29.09 * 2;
- calculate = 2 * (226 * 29.09) + daysOfStaying;
- }
- else
- {
- validNumberOfDays = false;
- }
- }
- else
- {
- validPlanet = false;
- }
- if (!validPlanet)
- {
- Console.WriteLine("Invalid planet name!");
- }
- else if (!validNumberOfDays)
- {
- Console.WriteLine("Invalid number of days!");
- }
- else
- {
- Console.WriteLine("Distance: {0}", $"{distance:F2}");
- Console.WriteLine("Total number of days: {0}", $"{calculate:F2}");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement