In: Computer Science
Program on Visual Basic, VBA
Create an application that lets the user enter a number of seconds and produces output according to the following criteria:
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 days in that many seconds.
Code:-
Module Module1
Sub Main()
Dim sec As Double
'declare MC variable for calculate the minutes in given
seconds
Dim MC As Double
'declare HC variable for calculate the hours in given seconds
Dim HC As Double
'declare DC variable for calculate the days in given seconds
Dim DC As Double
'get the seconds from user
Console.WriteLine("Enter the seconds: ")
sec = Console.ReadLine()
'check the seconds
If sec >= 60 And sec < 3600 Then
MC = sec / 60
Console.WriteLine("Minutes: " & MC)
Elseif sec >= 3600 And sec < 86400 Then
HC = sec / 3600
Console.WriteLine("Hours: " & HC)
Elseif sec >= 86400 Then
DC = sec \ 86400
Console.WriteLine("Days: " & DC)
End If
End Sub
End Module
Code Screenshot:-
Output:-
Please UPVOTE thank you...!!!