November 13th, 2009, 04:44 AM
help the student pls
Hi! I am doing the Uni work and i stuck with 1 little thing, if anyone can help will be happy!
here is the exercise:
Write a method named SecsIn which accepts three integers representing time in hours, minutes and seconds.
Your method should output the total time in seconds represented by the values.
the problem is:
i want to make it that way, so if user enters the value for hour, minute or second greater then 60, he would be told to do it again, and the program would calculate only if the values are right. So far it calculates even if they are wrong, but gives the message.
static void Main(string args)
Console.WriteLine("Calculate the Time\nEnter the value of hour, minute and second\nThe value of them can not be greater then 60");
Hour = int.Parse(Console.ReadLine());
Minute = int.Parse(Console.ReadLine());
Sec = int.Parse(Console.ReadLine());
if (Hour <= 60 && Minute <= 60 && Sec <= 60)
Console.WriteLine("The Time is");
Console.WriteLine("Wrong values Enter the values again");
SecsIn(Hour, Minute, Sec);
static void SecsIn(int hour, int min, int sec)
Console .WriteLine ((hour*60) * (min*60 ) + 60 + sec);
Thank you all for helping!
November 13th, 2009, 04:58 AM
Re: help the student pls
sorry, nevermind!!! sorted myself
Click Here to Expand Forum to Full Width