Create an application that lets the user enter a number of seconds and works as
ID: 3672824 • Letter: C
Question
Create an application that lets the user enter a number of seconds and works as follows:
There are 60 seconds in a minute. If the number of seocnds entered by the user is greater than or equal to 60, the program should display the number of minutes in that many seconds,
There are 3600 seconds in an hour. If the number of seconds entered by the user is greater than or equal to 3600 the program should display the number of hours in that many seconds.
There are 86400 seconds in a day. If the number of seconds entered by the user is greater than or equal to 86400, the program should display the number of days in that many seconds.
Please send also the how to do it on Visual Studio 2012 and the solution in the window. and I need it in C#
Explanation / Answer
using System;
public class Test
{
public static void Main()
{
int seconds = Convert.ToInt32(Console.ReadLine());
if(seconds >= 86400){
Console.WriteLine("Number of days: " + (seconds / 86400));
}
else if(seconds >= 3600){
Console.WriteLine("Number of hours: " + (seconds / 3600));
}
else if(seconds >= 60){
Console.WriteLine("Number of minutes: " + (seconds / 60));
}
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.