I Have been working on this for a few days now, and I seem to be missing something. What I have to do is:

Design a C# solution with a Main ( ) method that holds an integer variable named seconds to which you will assign a value. Create a method to which you pass this value. The method displays the seconds in minutes and seconds. As an example 66 seconds is 1 minute and 6 seconds.

Add a second method to the solution. This method displays a passed argument as hours, minutes and seconds. For example 3666 seconds is 1 hour, 1 minute and 6 seconds.

Add a statement to the Main ( ) method so that after it calls the methods to convert seconds to minutes and seconds, it passes the same value to the new method to convert it to hours, minutes and seconds.

Here is what I have so far:

static void Main()
{
int seconds=9691;
timeCal(ref seconds);
Console.WriteLine("{0) seconds equals {1} minute and {2} seconds",seconds,minutes);


}


static void timeCal(ref int Seconds)
{


hour = seconds /(60*60);
minutes = seconds / 60%60;
calSeconds = seconds % 60;
Console.WriteLine(" {0} seconds equal {1} hour, {2} minutes and {3} seconds.",seconds,minutes,hour,calSeconds);


}

I keep getting the errors:

the name 'calSeconds' does not exist in class or namespace
the name 'minutes' does not exist in class or namespace
the name 'hour' does not exist in class or namespace

I first figured that I didn't initilaize them, but when I did, I got the same errors. I'm completely stuck as to what I'm supposed to be adding so they will exist. Any clues will be well appriciated ;)

Thanks
Shanir

Edited 3 Years Ago by happygeek: fixed formatting

//Project Name:         Lab4_
//Project Purpose:      Creates a Main method that stores seconds
//                      passes the variable to a conversion method that converts
//                      the variable seconds to minutes and seconds remaining
//                      then returns a value to the main, where it is again
//                      converted to hours, minutes, and seconds.



using System;
public class Lab4_
{
public static void Main()
{
string inputSeconds;                    //stores the user input data of seconds.
int seconds;                            //stores the value of seconds after converted from string.
int minutes = 60;                       //stores the number of seconds in a minute.



//Prompts the user for the number of seconds
//and reads the data into the program


//write a console.readline statement here to get the user to input the number of seconds


//converts the user data from string to int32.
seconds = Convert.ToInt32(inputSeconds);



//Calls the method to calculate the minutes from seconds.
//passes the variables seconds and minutes to the method.
ComputeMinutesFromSeconds(seconds, minutes);


}


//Method to calculate the number of minutes and remaining seconds
//from the user input data.
public static void ComputeMinutesFromSeconds(int seconds, int minutes)
{
int totalMinutes;                       //stores the value of minutes after the calculation.
int remainingSeconds;                   //stores the value of seconds remaining after the calculation.


//Write code here for calculating the minutes and seconds.


//Calls the method to calculate the number of hours in the given number.
//of minutes stored in the variable totalMinutes.
//passes all needed arguements to complete the calculations.
ComputeHoursFromMinutes(totalMinutes, minutes, seconds, remainingSeconds);


}



//Method to calculate the number of hours, minutes, and remaining seconds.
//from the totalMinutes calculated in the ComputeMinutesFromSeconds method.
//declares the necessary variables to complete the calculation.
public static void ComputeHoursFromMinutes(int totalMinutes, int minutes, int seconds, int remainingSeconds)
{
int totalHours;                         //stores the value of total hours after the calculation.
int remainingMinutes;                   //stores the remaining minutes after the calcuation.


//write code here for calculating hours and minutes.


//Outputs to the console screen the number of minutes, and seconds remaining
//from the number of seconds given by the user.
//Put your WriteLine statement here for minutes and seconds.



//Outputs to the console screen the number of hours, minutes, and seconds after the calculations
//from both methods.


//Put a writeline statement here for hours, minutes, and seconds.



}
}

Edited 3 Years Ago by happygeek: fixed formatting

I new to C# to and I working the same project. Can you give me some assitance.

Thanks

This question has already been answered. Start a new discussion instead.