❔ 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.
7 Replies
i dont know
i am strugling to understend how i apply the name at the end
next to the max and min height
can you tell me how i do that ?
hello ?
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;
}
}
}
}
}
so far i did this
i am cluless as to how to go from here can you please explain to me what i need to do
yeah but they have to be the names of the ones that scored the higest numbers and the smallest numbers
also
why is it that i always get minum height= 0
so what should i do
do i remove the 0
i removed the 0 its still giving me zero as a result
so all i have to do is type in midnight=99999
that dosent work ethir
i recived a minheight equals 99999 at the end
for some reson the if dosent work
what do you mean
the program is supposed to give me the smallest and bigest number
but insted it gave me what i typed in as minhiehgt at the start
i would not say not working rather not doing its job and its the if thats supposed to carry out the minheight job
man please help me understand what i am doing wrong
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); } } }
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); } } }
Toshiya Joshima#3472
REPL Result: Success
Result: int
Compile: 416.134ms | Execution: 22.832ms | React with ❌ to remove this embed.
what
does that mean
what does math.clamp do
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); } } } for some reson only if i remove the string name and everything related to the name the program actuly funcations
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); } } } for some reson only if i remove the string name and everything related to the name the program actuly funcations
0 for minimum value
25 is maximum value
30 is actual value
if it exceeds those values it'll clamp up to closer limit
sorry my bad
first parameter is actual value
Toshiya Joshima#3472
REPL Result: Success
Result: int
Compile: 433.353ms | Execution: 24.169ms | React with ❌ to remove this embed.
you see -5 is not in range between 0 and 30
it'll round upto 0
Was this issue resolved? If so, run
/close
- otherwise I will mark this as stale and this post will be archived until there is new activity.