+ 1
Wondering if there is something I could do differently
So if I have 3 inputs, and the medium of those inputs is the output, Is there a way for it to count how many inputs I have automatically so I donât have to divide it specifically by what I have already, which would be 3, like if I wanted the amount of inputs to be changeable, like you can put in 2, but you could also put in 3 or 4 inputs Sorry if my wording is terrible Iâm not very good with words
2 Answers
+ 1
Do you mean that you want to Count the Inputs you give out or that you want to make a special number of Inputs.
For counting the Inputs would a list be good.
List<string> animals = new List<string>();
string animal;
while(animal != "stop")
{
animal = Console.ReadLine();
if(animal != "stop")
{
animals.Add(animal);
}
}
Console.WriteLine(animals.Count);
When you want to have a self decided number of Inputs just make a Input for that.
Console.WriteLine("Give in a number of Inputs")
List<string> Inputs = new List<string>();
int count = ToInt32(Console.ReadLine());
for(int i = 0; i <= count; i++)
}
Inputs.Add(Console.ReadLine());
}
+ 2
You can specify the desired number of inputs in the first input and use this value in the loop for subsequent data input.