9 Replies
For now, it just adds on every line (aka "car isn't new, car is new etc etc) onto every text you enter.
How can I make it work properly?
modelcar
is an array of strings, you cannot put an int to it
assuming this is a school assignment, you haven't learned about classes yet?
else
also has unneeded ;
and the if
aswell
the int array yearcar
seems redundant
Console.ReadLine()
I suggest you look into int.TryParse
Console.WriteLine
makes no senseyeah, we haven't classes yet
for (int i = 0; i < 10; i++)
{
Console.Write("Enter a model of your car {0}:", i + 1);
modelcar[i] = Console.ReadLine();
retry:
Console.Write("Enter a year of production {0}:", i + 1);
if (int.TryParse(Console.ReadLine(), out yearcar[i]))
{
if (yearcar[i] >= 2020)
{
Console.WriteLine(" The car is new.");
}
else
{
Console.WriteLine(" The car isn't new.");
}
}
else {
Console.WriteLine(" Invalid year. Please, enter again.");
goto retry;
}
}
your program is modified so that it works properlly
something we do here
what?
the idea is to let people learn, and not give them the answer
aka spoonfeed
got it
Thank you very much
ššš