Computer Science Canada Urgent Major Problem |
Author: | jess25 [ Thu Nov 28, 2002 1:37 pm ] |
Post subject: | 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 |
Author: | FizixMan [ Thu Nov 28, 2002 4:01 pm ] | ||
Post subject: | |||
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
Then at the end, you can output your numbers and multiply by 2.2 at the same time. I probably could have given you less code than this, but I'm pressed for time and it was just easier to post bits of the code. |
Author: | Tony [ Thu Nov 28, 2002 6:48 pm ] | ||||
Post subject: | |||||
hey FixizMan, you forgot the fact that you can't add heights in "feet, inches" format... Try adding 5 10 and 6 2, what do you get? 12! To add them up (and to find the largest one), you gotta convert height to inches only. So
then when you found the average, you convert it to metric system:
|
Author: | FizixMan [ Thu Nov 28, 2002 7:16 pm ] |
Post subject: | Re: Urgent Major Problem |
jess25 wrote: The program should allow the user to input the value for several basketball players and their height in inches.
Thanks pshhhhhhhhhhhhhh Look who's talking man... he didn't say anything about inputting it as feet and inches... just their height in inches... so on you haha; it's all good man. |
Author: | Tony [ Thu Nov 28, 2002 10:10 pm ] |
Post subject: | Re: Urgent Major Problem |
FizixMan wrote: jess25 wrote: The program should allow the user to input the value for several basketball players and their height in inches.
Thanks lol, read what you quote |
Author: | FizixMan [ Fri Nov 29, 2002 2:42 am ] |
Post subject: | |
ummm..... *reads through the post again* I still don't see the word "feet" in it... so I dont' see where you're getting this from man... I imagine the input isn't feet & inches, JUST inches. So if they're 6'0", the input would be 72. I think that's what he means... but whatEVrrrrrrrrrr it could be either way I guess, and we got both possibilities covered... (darn Imperial System... ) |
Author: | Stuperman [ Fri Nov 29, 2002 4:44 am ] |
Post subject: | |
one thing there is 2.5 cm in one inch..... |
Author: | FizixMan [ Fri Nov 29, 2002 1:47 pm ] |
Post subject: | |
Actually... it's 2.54 cm/inch (why are we still going on aboot this??? lol) |
Author: | Tony [ Fri Nov 29, 2002 5:59 pm ] |
Post subject: | |
well I always thought it was 2.5... but the guy asked for 2.2, so meh... maybe he's from some remote place? anyway, when you're asked for your height in inches, you usually use feet... but w/e... We already figured out this problem. Just saying that if you're to look up some stats for b-ball players... their height would have feet |
Author: | FizixMan [ Sat Nov 30, 2002 6:18 pm ] |
Post subject: | |
but considering the difficulty (or rather, the simplicity) of it suggests that inputing both the feet and inches is a bit much over just inputing a single integer for the total inches. (funny how we are still arguing over such a triviality... it's fun eh? ) |
Author: | Dan [ Sat Nov 30, 2002 6:46 pm ] |
Post subject: | my god |
this is going a litte nuts here, i think this is satring to be one of those topics that needs to be loked. oh well i kind of whont to see how long you guys are going to go on about this any way |
Author: | Tony [ Sat Nov 30, 2002 8:48 pm ] |
Post subject: | |
Dan, I don't think that locking the topic would do any good as a continue on topic might be created... Or I can just unlock the topic And yes, simplicity... You might as well ask the user to input all heights in cm right away and in order! I mean come on, the purpose of programming is to get computers to do the thinking for us, not make metters worse by making user figure out what to input. I mean to enter the height in inches, you must first figure out what it is by converting feet to inches, in that case it would be easier to let computer do that for you. |
Author: | FizixMan [ Sun Dec 01, 2002 6:12 am ] |
Post subject: | |
umm... umm... errr... uhhh... RATS! ... hmmm... Imperial system sucks! Metric FOREVER!!!!! *runs away* |
Author: | Tony [ Sun Dec 01, 2002 2:18 pm ] |
Post subject: | |
YES! I WIN! hehe, metric rocks, thast why the program converts feet to cm So you can stay and chill here @ SWAT. |