help the student pls
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums
Results 1 to 2 of 2

Thread: help the student pls

  1. #1
    Join Date
    Oct 2009

    Talking 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.

    my code:
    namespace HoursMinsSecs
    class Program
    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");

    int Hour;
    int Minute;
    int Sec;
    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!

  2. #2
    Join Date
    Oct 2009

    Re: help the student pls

    sorry, nevermind!!! sorted myself

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Windows Mobile Development Center

Click Here to Expand Forum to Full Width

On-Demand Webinars (sponsored)