Re: Woops, forgot the code.

  • From: Tyler Littlefield <tyler@xxxxxxxxxxxxx>
  • To: programmingblind@xxxxxxxxxxxxx
  • Date: Wed, 7 Jul 2010 07:49:20 -0600

Besides my comments, congrats on the first program. Looks good with what 
everyone else has said, too. I didn't explain order of operations well, but 
that's something you can google and get a good answer on.

                Thanks,
Tyler Littlefield
        http://tds-solutions.net
        Twitter: sorressean

On Jul 7, 2010, at 7:45 AM, Tyler Littlefield wrote:

> You also need to test. Feed this some numbers, then put the same numbers into 
> a calculator and see what the differences are. You will need to learn to test 
> your code.
>               Thanks,
> Tyler Littlefield
>       http://tds-solutions.net
>       Twitter: sorressean
> 
> On Jul 7, 2010, at 7:35 AM, Jared Wright wrote:
> 
>> Aside from the suggestions related to operator precedence others have 
>> mentioned, just a couple aesthetic notes.
>> 1. You don't have any newline characters in your program's output. So all 
>> the output of your program will run on one line. You might try:
>> cout<< "This program takes three test score numbers you enter, and figures 
>> out the
>> average for you. \n";
>> This way there will be a newline after that line of output.
>> 
>> Also, I was originally a little confused at why you switched between sintax 
>> when initializing the score variables. For the first two, you did var=0, but 
>> for the third you did var(0). 
>> Again, these are not actual problems with the code at all technically, but 
>> if anyone else were to do anything further with your code these things may 
>> be unclear to them at first. Given the scope of most meaningful projects 
>> requiring collaboration between programmers, I thought it important to get 
>> in the habit very early on of coding with the understanding that someone 
>> else might need to review and understand your code. These are just a couple 
>> of tips related to that.  Nice work!
>> 
>> 
>> On 7/7/2010 4:08 AM, Jes wrote:
>>> Here's the code.
>>> //Ch5 Exercise 4, page 287 //Calculates and displays the average of three 
>>> test scores
>>> //created/revised by Jes Smith on July 5 2010
>>> 
>>> #include <iostream>
>>> 
>>> using namespace std;
>>> //begin program
>>> int main()
>>> {
>>> //declare variables
>>> double score_1=0;
>>> double score_2=0;
>>> double score_3 (0);
>>> int answer;
>>> cout<< "This program takes three test score numbers you enter, and figures 
>>> out the average for you. ";
>>> cout<< "Please enter your first test score, then press enter. Decimal 
>>> values accepted: " ;
>>> cin >> score_1 ;
>>> cout<< "Please enter your second  test score. Remember to press enter when 
>>> done: ";
>>> cin >>score_2  ;
>>>                cout<< "Finally, enter your third   test score.";
>>> cin >>score_3  ;
>>> answer = score_1+score_2+score_3/3;
>>> cout<<"The average is " <<answer;
>>> 
>>> return (0);
>>> } //end of main function.
>>> 
>> 
> 
> __________
> View the list's information and change your settings at
> //www.freelists.org/list/programmingblind
> 

__________
View the list's information and change your settings at
//www.freelists.org/list/programmingblind

Other related posts: