Test Average and Grade

I am not able to get it to post my average

Page 1 of 1

3 Replies - 681 Views - Last Post: 09 April 2009 - 10:30 PM Rate Topic: -----

#1 alexandru80  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 09-April 09

Test Average and Grade

Post icon  Posted 09 April 2009 - 07:09 AM

//this is what I have. It's not calculating my average. please help
#include "stdafx.h"
#include <iostream>
#include <string>

using namespace std;
 double calculateGrade (double score)
{
   if (score<=100 && score>=90)
   {
	  cout << "You got an A" << endl;  
   }
   else
   {
	  if (score>=80 && score<=89)
	  {
		 cout << "You got an B" << endl;	 
	  }
	  else
	  {
		 if (score>=70 && score<=79)
		 {
			cout << "You got an C" << endl;	  
		 }
		 else
		 {
			if (score>=60 && score<=69)
			{
			   cout << "You got an D" << endl;  
			}
			else
			{
			   if (score<60)
			   {
				  cout << "You got an F" << endl;   
			   }
			   
			}
		 }
	  }
  
   }
return score;
}

 

int _tmain(int argc, _TCHAR* argv[])

{
   int total;
  int score;
  int i;
  int average=0;
i =1;
   cout << "Your score must be between 0 and 100" << endl;   
   total =0;
   while (!(i>5))
   {
	  cout << "what is your score?" << endl;
	  cin >> score;
	  i =i+1;
	  calculateGrade(score);
	  total =total+score;

   }
}

double calculateAverage ( double total)
{
double average;
   average =total/5;
	  cout << "your average is "<<average << endl;
return 0;

 }


This post has been edited by alexandru80: 09 April 2009 - 09:07 AM


Is This A Good Question/Topic? 0
  • +

Replies To: Test Average and Grade

#2 janotte  Icon User is offline

  • code > sword
  • member icon

Reputation: 990
  • View blog
  • Posts: 5,141
  • Joined: 28-September 06

Re: Test Average and Grade

Posted 09 April 2009 - 07:17 AM

Welcome to DIC!

Please click the edit button on your posting.

Cut out all the code and repost it between code tags :code:

Until you do it's unlikely anyone will read your posting and help you.
Was This Post Helpful? 0
  • +
  • -

#3 alexandru80  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 09-April 09

Re: Test Average and Grade

Posted 09 April 2009 - 09:01 AM

View Postjanotte, on 9 Apr, 2009 - 06:17 AM, said:

Welcome to DIC!

Please click the edit button on your posting.

Cut out all the code and repost it between code tags :code:

Until you do it's unlikely anyone will read your posting and help you.

thank you
Was This Post Helpful? 0
  • +
  • -

#4 janotte  Icon User is offline

  • code > sword
  • member icon

Reputation: 990
  • View blog
  • Posts: 5,141
  • Joined: 28-September 06

Re: Test Average and Grade

Posted 09 April 2009 - 10:30 PM

I can't see anywhere that you are calling the calculateAverage() function.

Am I looking straight through that call?

If not you will need to add:
calculateAverage(total);
to a relevant location in your main()
Was This Post Helpful? 1
  • +
  • -

Page 1 of 1