This is my current code:
string userName = "";
int v1 = 0, v2 = 0, v3 = 0, v4 = 0, v5 = 0;
int sum = 0;
float avg;
float variance;
Console.WriteLine("Please enter your name:");
userName = Console.ReadLine();
Console.WriteLine("Please enter in a number between 10 and 50: ");
int inputCheck = 0;
inputCheck = Convert.ToInt32(Console.ReadLine());
for (int i = 0; i <= v5; i++)
{
if (i == v1)
{
v1 = inputCheck;
if (v1 < 10 || v1 > 50)
{
Console.WriteLine("The number you have entered is invalid please enter a new variable: ");
}
continue;
}
if (i == v2)
{
v2 = inputCheck;
if (v2 < 10 || v2 > 50)
{
Console.WriteLine("The number you have entered is invalid please enter a new variable: ");
}
continue;
}
if (i == v3)
{
v3 = inputCheck;
if (v3 < 10 || v3 > 50)
{
Console.WriteLine("The number you have entered is invalid please enter a new variable: ");
}
continue;
}
if (i == v4)
{
v4 = inputCheck;
if (v4 < 10 || v4 > 50)
{
Console.WriteLine("The number you have entered is invalid please enter a new variable: ");
}
continue;
}
if (i == v5)
{
v5 = inputCheck;
if (v5 < 10 || v5 > 50)
{
Console.WriteLine("The number you have entered is invalid please enter a new variable: ");
}
continue;
}
I'm getting the console to correctly identify that if v1 is greater than 50 or less than 10 it gives the message. But the code stops and doesn't continue asking for variables. I've tried following what is happening in the for loop and the if's loop but I'm just getting lost. I'm tasked with getting 5 variables by using loops and one console.readlin();. If that helps at all as to why I'm asking this question.