[prog] validate input
wolf
wolf at wolfrising.net
Mon Dec 22 11:47:42 EST 2003
Hey, thanks so much to everyone for their hints and suggestions, the
code is working
now, and for the most part I understand what I should have been doing.
Again, lots
of great notes!!
Happy Holidays!!
Thanks : )
On Dec 22, 2003, at 2:53 AM, Jenn Vesperman wrote:
> On Mon, 2003-12-22 at 12:23, wolf wrote:
>> Also, if there's
>> a way to improve the comments, or if the indentation is incorrect,
>> please feel free to point that out as well. I'd like to break
>> any bad habits at the beginning. Thanks : )
>>
>
> Here, include a comment stating what the program is trying to achieve,
> how to use it, and who wrote it, when, and for what company (if any).
>
>> #include <iostream>
>>
>> using std::cout;
>> using std::cin;
>> using std::endl;
>>
>>
>> int main()
>>
>> {
>>
>> // initialize
>
> Initialise what? What is each variable for? Where is it used?
>
>> int passes = 0;
>> int failures = 0;
>>
>> int studentCounter =1;
>>
>>
>> int result;
>>
>>
>>
>>
>>
>> // 10 students
>
> Ten students what? Why are there ten students? What are they doing? Why
> do we care?
>
>> while ( studentCounter <= 10 ) {
>>
>>
>>
>> cout << "Enter result (1 = pass, 2 = fail): ";
>> cin >> result;
>>
>> if ( result == 1
>> )
>
> What is this if statement (or set of statements) for?
>
>
>> passes = passes + 1;
>> else
>
> I'm not sure if you have 'elseif' as a specific command, if so, use it
> and check if the result is 2.
> Otherwise, embed a second if.
>
>> failures = failures + 1;
>
> Else, if the result is neither 1 nor 2, print your error.
>
>> studentCounter = studentCounter +1;
>> }
>
> What's this bit of code for? It's worth putting in comments announcing
> each major change in code purpose. Announce initialisations, and the
> purposes of variables. Announce when you're in the part that does
> calculations. And here, announce that you're in the output.
>
>> cout << "Passed " << passes << endl;
>> cout << "Failed " << failures << endl;
>
> Why do we raise tuition at 8?
>
>> if (passes >= 8)
>> cout << "Raise Tuition " << endl;
>>
>> return 0;
>>
>> }
>
>
>
>
> Jenn V.
> --
> "Do you ever wonder if there's a whole section of geek culture
> you miss out on by being a geek?" - Dancer.
> My book 'Essential CVS': published by O'Reilly in June 2003.
> jenn at anthill.echidna.id.au http://anthill.echidna.id.au/~jenn/
>
>
> _______________________________________________
> Programming mailing list
> Programming at linuxchix.org
> http://mailman.linuxchix.org/mailman/listinfo/programming
>
More information about the Programming
mailing list