|
-
July 28th, 2010, 03:21 AM
#22
Re: why is it skipping lines?
With all due respect, I find it strange that you are unable to understand while loops and do-while loops.
I think probably what it comes down to, is that you are in a panic about all you have to do this week, and you are not giving yourself time to stop and think properly about your assignment. "I don't have time to think about it" you might say, but, if you take a deep breath, try to relax and apply your mind to the subject at hand, I would be very surprised if you cannot understand while loops within 60 seconds.
Once you understand the while loop I would again be very surprised if it takes you more than another 90 seconds (given all the help you've been given on this forum) to understand how to correctly apply it to your program. It should only take you 5 minutes to make the changes to your code. However, even if it takes you 20 minutes (which it really shouldn't), we'd only be asking that you use 22.5 minutes out of your whole week to ammend your a program so that it is correctly designed and implemented. It will get you a better grade, and you will have a better understanding.
The thing is, while loops are exactly as they read:
Code:
while( the condition is true)
{
//do whatever is within these curly braces.
}
//If we're here then the condition is not true anymore
For example
Code:
bool counted_to_five = false;
int count = 1;
//remember ! means 'not'
while(!counted_to_five) //while not counted to five
{
//If count is equal to 5
if(count==5)
{
//set counted_to_five to true
counted_to_five = true;
//This will mean that !counted_to_five will now resolve to false
//and the while loop will finish.
}
else
{
//increment count
++count;
}
}
You do not need to understand any more than the above while loop to fix your code. Paul has already given you a suitable solution when he wrote the following pseudo code:
 Originally Posted by Paul McKenzie
Code:
start program
set selection to 'a'
while selection is not 'q'
{
display menu and get selection
if ( selection is 'a') do a stuff
if ( selection is 'b') do b stuff
}
end program
 Originally Posted by CyberShot
The program doesn't get graded on being flawless.
I don't think you are in a position to judge on that. I've had a fair amount of experience of marking University Students work (though mainly for physics rather than programming). When I've done marking I've always judged against a flawless answer (and we were encouraged to do so by the head of department). The point is, if the lecturer or marker doesn't do that, then they have no reference point for how to grade the answers, everything becomes relative or subjective and students often get dealt unfair marks - those who get marked too high don't push themselves to learn as they should, and those who get marked too low often become despondent with their results never really understanding why their mark is so low. The only fair thing to do in subject where there are concrete right and wrong anwers it to mark against a 'flawless' answer.
In programming terms I would expect your program to be logically correct - which it isn't at present. The opinion of most here is that your program will get marked down if you leave it as it is. We're trying to help you, and we're not asking you to spend hours on it, but just a number of dedicated minutes instead.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|