Re: Woops, forgot the code.

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

Looks fine, though:
average=(s1+s2+s3)/3
Order of operations and all. And it's going to kill the decimal point, so you 
need to make answer a float or a double. I bet that's where your warning was.

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

On Jul 7, 2010, at 2: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

Other related posts: