Math Formula

I need help trying to write the math formula for a c++ program that ca

Page 1 of 1

2 Replies - 2869 Views - Last Post: 15 June 2008 - 04:45 PM Rate Topic: -----

#1 swilson23  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 29
  • Joined: 15-June 08

Math Formula

Posted 15 June 2008 - 04:14 PM

/*Program One*/

#include <iostream>
using namespace std;

double getGrade(int gradeNum){
		double grade;
		if(gradeNum <= 6)
			  cout << "Please enter grade for program number " << gradeNum << ":  ";
	   else if(gradeNum >6 && gradeNum <=8)
			  cout << "Please enter grade for test number " << gradeNum-6 << ":  ";
	   cin >> grade;
	   return grade;//Prints out grade for the program and test number & inserts & returns grade
}



char letterGrade(double average){
  if ( average<=100 && average > 90)
	return 'A';

  else if ( average >80)
	return 'B';
  else if ( average > 70)
	return 'C';

  else if ( average >60)
	return 'D';

  else if ( average >= 0)
	 return 'F';//put in the average grade and it returns the char corresponding





}

int main()
{

 
  cout <<"class program #"<< endl
	   << "name email address" << endl << endl;

  //display initial program identification

  

  
  double sum=0;
 
  for(int i = 1; i<=8; i++)
	sum += getGrade(i);//compute average

  cout << "Your average grade is " << letterGrade(sum/8) << endl;
 
	return 0;//display average grade  
}


*mod Edit: added code tags

This post has been edited by NickDMax: 15 June 2008 - 04:16 PM


Is This A Good Question/Topic? 0
  • +

Replies To: Math Formula

#2 NickDMax  Icon User is offline

  • Can grep dead trees!
  • member icon

Reputation: 2250
  • View blog
  • Posts: 9,245
  • Joined: 18-February 07

Re: Math Formula

Posted 15 June 2008 - 04:17 PM

please use code tags: :code:

Your question was cut off, what is your question.

(BTW, the title and description section of a post are limited in length -- so you need to put information inside you post).
Was This Post Helpful? 0
  • +
  • -

#3 swilson23  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 29
  • Joined: 15-June 08

Re: Math Formula

Posted 15 June 2008 - 04:45 PM

View PostNickDMax, on 15 Jun, 2008 - 04:17 PM, said:

please use code tags: :code:

Your question was cut off, what is your question.

(BTW, the title and description section of a post are limited in length -- so you need to put information inside you post).




I'm sorry! I have to write a code that calculates the grade of a student that is graded on 6 programs (counts as 50% of grade) and 2 tests (counts as 50% of grade). I don't know how to write the math formula part of the code. I know I need to make the add the 6 programs and multiply it by .5 + test 1 +test 2 (.25). But I have no idea how to put that in code. That is the right formula right? How do I put that into the code that I already have?
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1