I have my coursework to hand in on Monday and I can't understand what's wrong with my code!
Console.WriteLine("Insert pupil's height (in cm):");
int height = int.Parse(Console.ReadLine());
Console.WriteLine("Insert pupil's age:");
int age = int.Parse(Console.ReadLine());
while(!(age>8) && !(height>170))
{
int a, b, ageA, ageB, heightA, heightB = 0;
if(age>8 || height>150)
{
a++;
ageA+=age;
heightA+=height;
}
else
{
b++;
ageB+=age;
heightB+=height;
}
Console.WriteLine("Insert pupil's height (in cm):");
height=int.Parse(Console.ReadLine());
Console.WriteLine("Insert pupil's age:");
age=int.Parse(Console.ReadLine());
}
Console.WriteLine("Group A's average age is "+ageA/a+", and average height is "+heightA/a);
Console.WriteLine("Group B's average age is "+ageB/b+", and average height is "+heightB/b);
Thanks a lot!
Hayleigh.


Sign In
Create Account

Back to top









