Hello, my current assignment states this: "Modify the console application you created in HW1 in the following manner. Instead of using five Console.ReadLine() statements to read the user’s input into the five variables, use one Console.ReadLine() statement that’s inside a loop that executes five times. The rest of your code works like HW1 part 1 and 2 (i.e. compute the average and the variance of the five integers). Please note, to get all 70 points you MUST accurately compute both the mean and the variance. Use the following equation for the variance."
The last assignment from HW1 was pretty simple, we just had to heave the user input 5 variables, and it figured out the average and variance.
Here is what I have come up with so far:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Assignment_1_ITM_225
{
class Program
{
static void Main(string[] args)
{
int Integer1 = 0;
int Integer2 = 0;
int Integer3 = 0;
int Integer4 = 0;
int Integer5 = 0;
int intValue = 0;
int Integers = 0;
float Average = 0;
double Variance = 0;
Console.WriteLine("Please enter 5 integers between 10 and 50: ");
if (intValue < 10 || intValue > 50)
{
Console.WriteLine("{0} is not an integer between 10 and 50", intValue);
}
while (Integers < 5)
{
}
Console.ReadKey();
Integer1 = Convert.ToInt32(Console.ReadLine());
Integer2 = Convert.ToInt32(Console.ReadLine());
Integer3 = Convert.ToInt32(Console.ReadLine());
Integer4 = Convert.ToInt32(Console.ReadLine());
Integer5 = Convert.ToInt32(Console.ReadLine());
Average = ((Integer1 + Integer2 + Integer3 + Integer4 + Integer5) / 5.0f);
Console.WriteLine("The average of the integers is {0}", Average);
Console.ReadKey();
Variance = ((Integer1 - Average) * (Integer1 - Average) + (Integer2 - Average) * (Integer2 - Average) + (Integer3 - Average) * (Integer3 - Average) + (Integer4 - Average) * (Integer4 - Average) + (Integer5 - Average) * (Integer5 - Average)) / 4;
Console.WriteLine("The variance of the integers is {0}", Variance);
Console.ReadKey();
}
}
}
I'm just not sure what I'm supposed to do with the integers to make it into a loop, also, the if statement is a separate part of the assignment to make sure the variables are between 10 and 50. Any help would be greatly appreciated on how to make it so the integers are a loop.