Computer Science Canada Programming C, C++, Java, PHP, Ruby, Turing, VB   Username:   Password: Wiki   Blog   Search   Turing   Chat Room  Members
Urgent Major Problem
Author Message
jess25

Posted: 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

FizixMan

Posted: Thu Nov 28, 2002 4:01 pm   Post subject: (No 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

 code: maxheight:=0 for count:1..INPUT get players(count) sum+=players(count) if maxheight

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.
Tony

Posted: Thu Nov 28, 2002 6:48 pm   Post subject: (No 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

 code: get feet get inches inches = inches + 12*feet //this is your total height

then when you found the average, you convert it to metric system:

 code: put averageHeight*2.2
Tony's programming blog. DWITE - a programming contest.
FizixMan

Posted: 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.
Tony

Posted: 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

Tony's programming blog. DWITE - a programming contest.
FizixMan

Posted: Fri Nov 29, 2002 2:42 am   Post subject: (No 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... )
Stuperman

Posted: Fri Nov 29, 2002 4:44 am   Post subject: (No subject)

one thing there is 2.5 cm in one inch.....
FizixMan

Posted: Fri Nov 29, 2002 1:47 pm   Post subject: (No subject)

Actually... it's 2.54 cm/inch

(why are we still going on aboot this??? lol)

Tony

Posted: Fri Nov 29, 2002 5:59 pm   Post subject: (No 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
Tony's programming blog. DWITE - a programming contest.
FizixMan

Posted: Sat Nov 30, 2002 6:18 pm   Post subject: (No 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? )
Dan

Posted: 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
Computer Science Canada Help with programming in C, C++, Java, PHP, Ruby, Turing, VB and more!
Tony

Posted: Sat Nov 30, 2002 8:48 pm   Post subject: (No 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.
Tony's programming blog. DWITE - a programming contest.
FizixMan

Posted: Sun Dec 01, 2002 6:12 am   Post subject: (No subject)

umm... umm... errr... uhhh... RATS! ... hmmm... Imperial system sucks! Metric FOREVER!!!!! *runs away*
Tony

Posted: Sun Dec 01, 2002 2:18 pm   Post subject: (No subject)

YES! I WIN!

hehe, metric rocks, thast why the program converts feet to cm

So you can stay and chill here @ SWAT.
Tony's programming blog. DWITE - a programming contest.
 Display posts from previous: All Posts1 Day7 Days2 Weeks1 Month3 Months6 Months1 Year Oldest FirstNewest First

Page 1 of 1  [ 14 Posts ]
 Jump to:  Select a forum  CompSci.ca ------------ - Network News - General Discussion     General Forums   -----------------   - Hello World   - Featured Poll   - Contests     Contest Forums   -----------------   - DWITE   - [FP] Contest 2006/2008   - [FP] 2005/2006 Archive   - [FP] 2004/2005 Archive   - Off Topic     Lounges   ---------   - User Lounge   - VIP Lounge     Programming -------------- - General Programming     General Programming Forums   --------------------------------   - Functional Programming   - Logical Programming   - C     C   --   - C Help   - C Tutorials   - C Submissions   - C++     C++   ----   - C++ Help   - C++ Tutorials   - C++ Submissions   - Java     Java   -----   - Java Help   - Java Tutorials   - Java Submissions   - Ruby     Ruby   -----   - Ruby Help   - Ruby Tutorials   - Ruby Submissions   - Turing     Turing   --------   - Turing Help   - Turing Tutorials   - Turing Submissions   - PHP     PHP   ----   - PHP Help   - PHP Tutorials   - PHP Submissions   - Python     Python   --------   - Python Help   - Python Tutorials   - Python Submissions   - Visual Basic and Other Basics     VB   ---   - Visual Basic Help   - Visual Basic Tutorials   - Visual Basic Submissions     Education ----------- - Student Life   Graphics and Design ----------------------- - Web Design     Web Design Forums   ---------------------   - (X)HTML Help   - (X)HTML Tutorials   - Flash MX Help   - Flash MX Tutorials   - Graphics     Graphics Forums   ------------------   - Photoshop Tutorials   - The Showroom   - 2D Graphics   - 3D Graphics     Teams ------ - dTeam Public

 Style: Appalachia blueSilver eMJay subAppalachia subBlue subCanvas subEmjay subGrey subSilver subVereor Search: