Create an application using Visual Studios in C# using if else if statement that
ID: 3590454 • Letter: C
Question
Create an application using Visual Studios in C# using if else if statement that lets the user enter a number of seconds and works as follows:
There are 60 seconds in a minute. If the number of seconds 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 3,600 seconds in an hour. If the number of seconds entered by the user is greater than or equal to 3,600, the program should display the number of hours in that many seconds.
There are 86,400 seconds in a day. If the number of seconds entered by the user is greater than or equal to 86,400, the program should display the number of hours in that many seconds.
Create an application using Visual Studios in C# using if else if statement that lets the user enter a number of seconds and works as follows:
There are 60 seconds in a minute. If the number of seconds 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 3,600 seconds in an hour. If the number of seconds entered by the user is greater than or equal to 3,600, the program should display the number of hours in that many seconds.
There are 86,400 seconds in a day. If the number of seconds entered by the user is greater than or equal to 86,400, the program should display the number of hours in that many seconds.
Create an application using Visual Studios in C# using if else if statement that lets the user enter a number of seconds and works as follows:
There are 60 seconds in a minute. If the number of seconds 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 3,600 seconds in an hour. If the number of seconds entered by the user is greater than or equal to 3,600, the program should display the number of hours in that many seconds.
There are 86,400 seconds in a day. If the number of seconds entered by the user is greater than or equal to 86,400, the program should display the number of hours in that many seconds.
Explanation / Answer
using System;
namespace DecisionMaking{
public class SecondsIfElse
{
public static void Main(string[] args)
{
Console.WriteLine("Enter seconds:");
int totalSeconds = Convert.ToInt32(Console.ReadLine());
int totalMinutes = totalSeconds / 60;
int totalHours = totalMinutes / 60;
int totalDays = totalHours / 24;
if(totalSeconds > 0 && totalSeconds < 60){
Console.WriteLine("Please Enter Seconds greater than or equal to 60");
}
else if (totalSeconds < 3600 && totalSeconds >= 60)
{
Console.WriteLine("Total Minutes :");
Console.WriteLine(totalMinutes);
}
else if (totalSeconds >= 3600 && totalSeconds < 86400)
{
Console.WriteLine("Total Hours : ");
Console.WriteLine(totalHours);
}
else if (totalSeconds >= 86400)
{
Console.WriteLine("Total Days: ");
Console.WriteLine(totalDays);
}
else{
Console.WriteLine("Please Enter Valid Seconds");
}
}
}
}
/*output:-
case1:
case2:
case3:
case4:
case5:
*/
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.