3 Replies - 5884 Views - Last Post: 01 March 2010 - 11:25 AM Rate Topic: -----

#1 Guest_Anthony*


Reputation:

C++ Grade average structure definition

Posted 01 March 2010 - 11:09 AM

Write a grading program for a class with the following grading policies;
there are two quizzes, each graded on the basic of 10 point
thre is one midterm exam and one final exam, each graded on the basis of 100 points
the final exam counts for 50% of the grade, the mideterm counts for 25% and two quizzes together count for total 25%.

Any grade of 90 or more is A, 80 or more is B, 70 or more is C, 60 or more is D, and less than 60 is F.
The program will read in the student's scores and output the student's record which consist of two quiz and two exam scores as well as the students's average numeric score for the entire course and the final letter grade, define and use a structure for the student record.

Not sure where the error is I don't see what I am missing its a structure that is not named.

#include<iostream>
using namespace std;

struct grades
{
    double total;
    double quiz_value;
    double midterm_value;
    double final_value;
};

void final_grade(grades& the_grades);

int main() 
{  
    grades data;
    final_grade(data);

    double quiz_value, midterm_value, final_value;

    quiz_value = (data.score_quiz + data.score_quiz2)*(.25);
    midterm_value =(data.score_midterm * .25);
    final_value = (data.score_final * .50);
    data.total = (quiz_value + midterm_value + final_value);
    
    cout.setf(ios::fixed);
    cout.setf(ios::showpoint);
    cout.precision(2);
    cout << "The accumlative score is: "
         << data.total << endl; 

    return 0;
}

void final_grade(grades& the_grades);
{

cout << "Enter the score of the first quiz: ";
cin >> the_grades.score_quiz;

cout << "Enter the score of the second quiz"; 
cin >> the_grades.score_quiz2;
cout << "Enter the score of the midterm";
cin >> the_grades.score_midterm;
cout << "Enter the score of the final";
cin >> the_grades.score_final;
}


char letterGrade (double numericGrade)
{
  char letter;

  if (numericGrade < 60)
    letter = 'F';
  else if (numericGrade < 70)
    letter = 'D';
  else if (numericGrade < 80)
    letter = 'C';
  else if (numericGrade < 90)
    letter = 'B';
  else
    letter = 'A';

  return letter;
}

This post has been edited by JackOfAllTrades: 01 March 2010 - 11:24 AM
Reason for edit:: Added code tags. PLEASE!!! [code]...PUT YOUR CODE IN HERE!!!...[/code]


Is This A Good Question/Topic? 0

Replies To: C++ Grade average structure definition

#2 sarmanu  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 966
  • View blog
  • Posts: 2,362
  • Joined: 04-December 09

Re: C++ Grade average structure definition

Posted 01 March 2010 - 11:15 AM

First of all, use code tags when posting. Secondly, you don't know the name of the variables inside your struct. Here:
the_grades.score_quiz;
the_grades.score_quiz2;
the_grades.score_midterm;
the_grades.score_final;
//etc


score_quiz, score_quiz2, score_final and score_midterm are NOT members of "grades" struct.
Please read here more about structs: http://en.wikipedia....C%2B%2B_classes
http://www.cplusplus...ial/structures/
Was This Post Helpful? 0
  • +
  • -

#3 jjl  Icon User is offline

  • Engineer
  • member icon

Reputation: 1072
  • View blog
  • Posts: 4,532
  • Joined: 09-June 09

Re: C++ Grade average structure definition

Posted 01 March 2010 - 11:16 AM

*EDIT sarmanu beat me lol

is there a problem?? well of the top i can see this
void final_grade(grades& the_grades);
{

	cout << "Enter the score of the first quiz: ";
	cin >> the_grades.score_quiz;
	cout << "Enter the score of the second quiz"; 
	cin >> the_grades.score_quiz2;
	cout << "Enter the score of the midterm";
	cin >> the_grades.score_midterm;
	cout << "Enter the score of the final";
	cin >> the_grades.score_final;
}



score_quiz, score_midterm, score final do not exist in your structure,
This is your structure see
struct grades
{
	double total;
	double quiz_value;
	double midterm_value;
	double final_value;
};


This post has been edited by ImaSexy: 01 March 2010 - 11:17 AM

Was This Post Helpful? 0
  • +
  • -

#4 JackOfAllTrades  Icon User is offline

  • Saucy!
  • member icon

Reputation: 6036
  • View blog
  • Posts: 23,423
  • Joined: 23-August 08

Re: C++ Grade average structure definition

Posted 01 March 2010 - 11:25 AM

I fixed the post...I had deleted the original post with the question and the OP reposted just the code.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1