
-----------------------------------
jess25
Thu Nov 28, 2002 1:37 pm

Urgent Major Problem
-----------------------------------
I need major help on writing a program I've tried writing it but I'm having problems. The program should allow the user to input the value for several basketball players and their height in inches. I should be able to ask the user how many players are to be entered, and have the program convert the players' heights from inches to centimeters (2.2 cms per inch.)And calculating the average height for those players and output the tallest player. 

Thanks

-----------------------------------
FizixMan
Thu Nov 28, 2002 4:01 pm


-----------------------------------
The best way to tackle this is to use an array.  Have the user input the number of basketball players (and consequently the size of the array).  When you get the integer input, you can declare the array with that variable:

var players:array 1..INPUT of real

Then, you need the user to input all the basketball player's heights which can be accomplished easily enough with a "for" loop.  And in the same loop, you can figure out the tallest player and the average height.  Just have one variable look for the tallest player while another one sums up all the heights (remember average is the sum of the heights divided by the number of players).  Also remember to assign a value of zero to the maxheight before you start the loop


maxheight:=0
for count:1..INPUT
get players(count)
sum+=players(count)
if maxheight