C#
C#

help

Root Question Message

daniel1
daniel111/20/2022
❔ for is tough

On sports day, the students compete in the high jump.

Write a program that accepts as input the name of each student and the result of their jump.

The output of the program is the name of the student who jumped the highest and his jump result, the name of the student who jumped the lowest and his jump result, and the difference between the two jumps.
daniel1
daniel111/20/2022
i dont know
daniel1
daniel111/20/2022
i am strugling to understend how i apply the name at the end
daniel1
daniel111/20/2022
next to the max and min height
daniel1
daniel111/20/2022
can you tell me how i do that ?
daniel1
daniel111/20/2022
hello ?
daniel1
daniel111/20/2022
class Program
{
static void Main(string[] args)
{
string name;
double height, maxheight, minheight;
for (int i = 1; i <= 20; i++)
{
Console.WriteLine("enter your name");
name = (Console.ReadLine());
Console.WriteLine("enter your height");
height = double.Parse(Console.ReadLine());
maxheight = height;
minheight = height;
if (height > maxheight)
{
maxheight = height;
}
if (height < minheight)
{
height = minheight;
}
}



}
}
}
daniel1
daniel111/20/2022
so far i did this
daniel1
daniel111/20/2022
i am cluless as to how to go from here can you please explain to me what i need to do
daniel1
daniel111/20/2022
yeah but they have to be the names of the ones that scored the higest numbers and the smallest numbers
daniel1
daniel111/20/2022
also
daniel1
daniel111/20/2022
why is it that i always get minum height= 0
daniel1
daniel111/20/2022
so what should i do
daniel1
daniel111/20/2022
do i remove the 0
daniel1
daniel111/20/2022
i removed the 0 its still giving me zero as a result
daniel1
daniel111/20/2022
so all i have to do is type in midnight=99999
daniel1
daniel111/20/2022
that dosent work ethir
daniel1
daniel111/20/2022
i recived a minheight equals 99999 at the end
daniel1
daniel111/20/2022
for some reson the if dosent work
daniel1
daniel111/20/2022
what do you mean
daniel1
daniel111/20/2022
the program is supposed to give me the smallest and bigest number
daniel1
daniel111/20/2022
but insted it gave me what i typed in as minhiehgt at the start
daniel1
daniel111/20/2022
i would not say not working rather not doing its job and its the if thats supposed to carry out the minheight job
daniel1
daniel111/20/2022
man please help me understand what i am doing wrong
daniel1
daniel111/20/2022
static void Main(string[] args)
{
string name;
double height, maxheight = 0, minheight=0;
Console.WriteLine("enter your name");
name = (Console.ReadLine());
Console.WriteLine("enter your height");
height = double.Parse(Console.ReadLine());


for (int i = 1; i <= 4; i++)

{

Console.WriteLine("enter your name");
name = (Console.ReadLine());
Console.WriteLine("enter your height");
height = double.Parse(Console.ReadLine());


if (height > maxheight)
{
maxheight = height;
}
if (height < minheight)
{
height = minheight;

}
}
Console.WriteLine("the highest jump was=" + maxheight);
Console.WriteLine("the lowest jump was=" + minheight);




}
}
}
daniel1
daniel111/20/2022
what
daniel1
daniel111/20/2022
does that mean
daniel1
daniel111/20/2022
what does math.clamp do
daniel1
daniel111/20/2022
public static void Main()
{



Console.WriteLine("enter your height");
double height = double.Parse(Console.ReadLine());
double max = height;
double min = height;


for (int i = 2; i <= 10; i++)

{



Console.WriteLine("enter your height");
height = double.Parse(Console.ReadLine());


if (height > max)
{
max = height;
}
if (height < min)
{
height = min;

}
}
Console.WriteLine("the highest jump was=" + max);
Console.WriteLine("the lowest jump was=" + min);

}
}
}
daniel1
daniel111/20/2022
for some reson
daniel1
daniel111/20/2022
only if i remove the string name and everything related to the name
daniel1
daniel111/20/2022
the program actuly funcations
Samarichitane
Samarichitane11/20/2022
0 for minimum value
Samarichitane
Samarichitane11/20/2022
25 is maximum value
Samarichitane
Samarichitane11/20/2022
30 is actual value
Samarichitane
Samarichitane11/20/2022
if it exceeds those values it'll clamp up to closer limit
Samarichitane
Samarichitane11/20/2022
sorry my bad
Samarichitane
Samarichitane11/20/2022
first parameter is actual value
Samarichitane
Samarichitane11/20/2022
you see -5 is not in range between 0 and 30
Samarichitane
Samarichitane11/20/2022
it'll round upto 0
ContactFrequently Asked QuestionsJoin The DiscordBugs & Feature RequestsTerms & Privacy