I have an application assignment from school that I have been working on and have gotten stuck on. I am not understanding some of the concepts to complete my program. It is simple and I have the basic structure down. Could someone assist me in understanding and completing my program? Below is the listed information:
The following is the overall application assignment:
Write a program to display the average of some numbers. Your program will consist of three user defined methods named GetNums(), CalcAvg(), and DspAvg(). In GetNums() prompt for and read in 3 real numbers from the keyboard. After reading in the numbers, call CalcAvg() passing the three numbers as input. CalcAvg() must RETURN (use the return statement) the average of the 3 numbers. After calling CalcAvg(), call DspAvg() to display the average and the three numbers entered. Your program must not contain any variables with class-wide scope (all variables must be declared inside a method). All method calls (GetNums(), CalcAvg(), and DspAvg() must be called from main()). Using proper passing is important.
Your output should closely resemble the following.
The average of 10.20, 89.50, and 17.60 is 39.10.
Round the average to two decimal places. Display all values with two decimal places.
GetNums() will have three arguments, all pass by out. CalcAvg() will have three arguments, all pass by copy. Do not use four! DspAvg() will have four arguments, all pass by copy.
Below is the following code I have written, but have gotten stuck, based on the requirements above.
static void Main(string[] args)
{
int nu1, nu2, nu3, cavg;
GetNums();
CalcAvg();
DspAvg();
}
static void GetNums()
{
Console.Write("Please enter nu1: ");
nu1 = int.Parse(Console.ReadLine());
Console.Write("Please enter nu2: ");
nu2 = int.Parse(Console.ReadLine());
Console.Write("Please enter nu3: ");
nu3 = int.Parse(Console.ReadLine());
CalcAvg(DspAvg);
}
static void CalcAvg()
{
}
static void DspAvg()
{
}
}
}