Student Grade Calculator

I am stuck on this...I can't go any farther until I undersand what

Page 1 of 1

2 Replies - 2040 Views - Last Post: 14 October 2009 - 10:12 PM Rate Topic: -----

#1 niki9  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 9
  • Joined: 14-October 09

Student Grade Calculator

Posted 14 October 2009 - 08:16 PM

#include<ioostream>
#include<iomanip>
using namespace std;

int main ()

{

    //Variables
    
    float sum;			//input of grades from the user
    float average;      //calculated result
    float first_grade   //student's first grade
    float second_grade	//student's secoond grade
    float third_grade	//student's third grade
    float drop_grade	//student's drop grade
    float final_grade	//student's final grade
    
    const int NUMBERS = 3;
    
    //Program Purpose
    
    cout << "This programe will determine the final grade of your History tests. You can\n"
         << "drop your lowest test grade. So it will add together the highest of the first\n"
         << "two grades and the third grade."<< endl << endl;
         
     //Prompt the user for the first grade
     
     cout << "\n Please enter the first test grade:  ";
     cin.sync();
     cin.clear();
     cin >> first_grade;
     
     //Prompt the user for the second grade
     
     cout << "\n Please enter the second grade:  ";
     cin.sync();
     cin.clear();
     cin >> second_grade;
     
     //Prompt the user for the third grade
     
     cout << "\n Please enter the second grade:  ";
     cin.sync();
     cin.clear();
     cin >> third_grade;
     
     //Ask the user which grade they would like to drop
     
     cout << "\n Which grade would you like to drop: ";
     cin.sync();
     cin.clear();     
     cin >> drop_grade;
     
     
    //Display the sum
    
    cout << "The final grade is" << final_grade << endl << endl;
    
    return 0;
    
 }


*** MOD EDIT: Added code tags. Please :code: ***

This post has been edited by JackOfAllTrades: 15 October 2009 - 05:15 AM


Is This A Good Question/Topic? 0
  • +

Replies To: Student Grade Calculator

#2 Ancient Dragon  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 81
  • View blog
  • Posts: 679
  • Joined: 19-July 09

Re: Student Grade Calculator

Posted 14 October 2009 - 08:35 PM

You posed your program -- without using code tags -- but you failed to ask a question.
Was This Post Helpful? 0
  • +
  • -

#3 barnwillyb  Icon User is offline

  • D.I.C Head

Reputation: 6
  • View blog
  • Posts: 108
  • Joined: 22-May 07

Re: Student Grade Calculator

Posted 14 October 2009 - 10:12 PM

View Postniki9, on 14 Oct, 2009 - 07:16 PM, said:

#include<ioostream>
#include<iomanip>
using namespace std;

int main ()

{

//Variables

float sum; //input of grades from the user
float average; //calculated result
float first_grade //student's first grade
float second_grade //student's secoond grade
float third_grade //student's third grade
float drop_grade //student's drop grade
float final_grade //student's final grade

const int NUMBERS = 3;

//Program Purpose

cout << "This programe will determine the final grade of your History tests. You can\n"
<< "drop your lowest test grade. So it will add together the highest of the first\n"
<< "two grades and the third grade."<< endl << endl;

//Prompt the user for the first grade

cout << "\n Please enter the first test grade: ";
cin.sync();
cin.clear();
cin >> first_grade;

//Prompt the user for the second grade

cout << "\n Please enter the second grade: ";
cin.sync();
cin.clear();
cin >> second_grade;

//Prompt the user for the third grade

cout << "\n Please enter the second grade: ";
cin.sync();
cin.clear();
cin >> third_grade;

//Ask the user which grade they would like to drop

cout << "\n Which grade would you like to drop: ";
cin.sync();
cin.clear();
cin >> drop_grade;


//Display the sum

cout << "The final grade is" << final_grade << endl << endl;

return 0;

}


This will get you started:

/*__________________________________________________________*/
/*																													*/
/*												 includes													*/
/*__________________________________________________________*/

#include <iostream>

// introduces namespace std
using namespace std;

/*__________________________________________________________*/
/*																													*/
/*						prototypes												*/
/*__________________________________________________________*/

char display_student_grades( int student_score );

/*__________________________________________________________*/
/*																													*/
/*											 main listing												*/
/*__________________________________________________________*/

int main ()

{
	
	//Variables
	float first_grade; //student's first grade
	float second_grade;	//student's secoond grade
	float third_grade;	//student's third grade
	float drop_grade;	//student's drop grade
	float final_grade;	//student's final grade
	
	//Program Purpose
	
	cout << "\n\tThis programe will determine the final grade of your History tests. You can\n"
	<< "\tdrop your lowest test grade. So it will add together the highest of the first\n"
	<< "\ttwo grades and the third grade."<< endl << endl;
	
	//Prompt the user for the first grade
	
	cout << "\tPlease enter the first test grade: ";
	cin.sync();
	cin.clear();
	cin >> first_grade;
	
	//Prompt the user for the second grade
	
	cout << "\t\t\tPlease enter the second grade: ";
	cin.sync();
	cin.clear();
	cin >> second_grade;
	
	//Prompt the user for the third grade
	
	cout << "\t\t\t Please enter the third grade: ";
	cin.sync();
	cin.clear();
	cin >> third_grade;
	
	//Ask the user which grade they would like to drop
	
	cout << "\n\tWhich grade would you like to drop: ";
	cin.sync();
	cin.clear(); 
	cin >> drop_grade;
	
	//Display the final grade
	final_grade = (first_grade + second_grade + third_grade - drop_grade)/2;
	
	cout << "\tThe final grade is " << display_student_grades( final_grade ) << "." << endl;
	
	return 0;
	
}

/*__________________________________________________________*/
/*																													*/
/*									 function definitions										*/
/*__________________________________________________________*/

// PRINT OUT STUDENT GRADES
char display_student_grades( int student_score ) {
	int i;

	for (i = 0; i < 10; i++) {
		if (student_score >= 90)
			return 'A';
		else if (student_score >= 79)
			return 'B';
		else if (student_score >= 69)
			return 'C';
		else if (student_score >= 62)
			return 'D';
		else if (student_score < 62)
			return 'F';
	}
	return '0';
}

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1