Computer Science Canada Turing Help for a beginner |
Author: | SIXAXIS [ Wed Jan 30, 2008 11:17 am ] | ||
Post subject: | Turing Help for a beginner | ||
Hi guys, I'm new here and I'm also new to Turing. I have to make a program that calculates the average, youngest, and oldest age in a class that's size is determined by the user. Here is what I have so far:
Whenever I run this, it works fine, but at the end, it says that the youngest, oldest, and average age is 0. What am I doing wrong? Is it the if statements? |
Author: | fishtastic [ Wed Jan 30, 2008 11:38 am ] | ||
Post subject: | Re: Turing Help for a beginner | ||
this works.
This is really simple so you should get this. also. use better variable names please. |
Author: | SIXAXIS [ Wed Jan 30, 2008 11:45 am ] |
Post subject: | Re: Turing Help for a beginner |
Thank you for your help. I understand it now. And yeah, after I posted this I changed the names in my Turing file, but didn't re-post it. |
Author: | syntax_error [ Wed Jan 30, 2008 2:05 pm ] |
Post subject: | Re: Turing Help for a beginner |
yes thank fishtastic since he/she just did your work for you how graces of him/her make sure you do understand the differnce in what he/she did for not always will someone here do the work for you btw fishtastic dont mind my satire here but next time just explain them what they need to do NOT do it for them |
Author: | fishtastic [ Wed Jan 30, 2008 2:55 pm ] |
Post subject: | Re: Turing Help for a beginner |
syntax_error @ Wed Jan 30, 2008 1:05 pm wrote: btw fishtastic dont mind my satire here but next time just explain them what they need to do NOT do it for them Yes.. perhaps I should use pseudo code instead. So people will try to understand it more. But, it was easier just to fix the problem and show the difference than explaning, becasue the problem already gave you the logic you need to solve it. |
Author: | ericfourfour [ Wed Jan 30, 2008 5:30 pm ] | ||||||
Post subject: | Re: Turing Help for a beginner | ||||||
Just a small improvement on this part:
It can be reduced to:
It's a shorter way to keep numbers within a range. It works like this:
|
Author: | HeavenAgain [ Wed Jan 30, 2008 5:44 pm ] | ||||||
Post subject: | RE:Turing Help for a beginner | ||||||
shorter doesnt mean better ![]() your method with
![]() though it can be shorten to
![]() |
Author: | fishtastic [ Wed Jan 30, 2008 5:55 pm ] | ||||||
Post subject: | Re: RE:Turing Help for a beginner | ||||||
ericfourfour this doesn't work. look at the situation.
HeavenAgain this doesn't always work either. there are chance where input is the oldest and the youngest but you only checked one that way. however
this does work! and its shorter! ![]() |
Author: | ericfourfour [ Wed Jan 30, 2008 6:34 pm ] |
Post subject: | RE:Turing Help for a beginner |
Woops. Misread his code. I read it like he was trying to keep the age within a range. The example fishtastic just concluded with is the better solution. |