Here is the first part of my program, it's too long to fit it all at once:
/**********************************************************************
*Program Name : CSC 110 Calc Students GPA
*Author :
*Due Date : May 12, 2014
*Course/Section : CSC 110 - 005
*Program Description:
*
*BEGIN Main Function
* Input the student name (or quit)
* WHILE (the student name is not the quit value)
* Call function to input the course info and calculate the grade points
* Clear the screen?
* Call function to calculate the gpa
* Call function to display the grade report
* Pause the screen
* Clear the screen
* Get the next student name (or quit)
* END WHILE
* Call function to display closing message (optional)
*END Main Function
*********************************************************************/
#include <cstdlib>
#include <iostream>
#include <iomanip>
#include <string>
#include <ctime>
#include <cmath>
using namespace std;
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88
|
//place prototypes here
float input (float Grade, float Hours, int Count, float Pts, float Grade_Array[],
float Hour_Array[], float Pts_Array[]);
float gpa (float Total_Gradepts, float Pts_Array[], float Total_Crdt,
float Hour_Array[], float Gpa);
bool validate(int Grade, int Hours);
void display (int Count, int SIZE, float Grade_Array[],
float Hour_Array[], float Pts_Array[], float Gpa);
void close();
int main()
{
//local constants
const int QUIT = -1; //Init Quit Value
const string QUIT_NAME = "-1"; //Init String Quit
const float GRADE_LOW = 0.0; //Set Grade Low to 0.0
const float GRADE_HIGH = 4.0; //Set Grade High to 4.0
const int HOUR_MIN = 1; //Set Hour Min to 1
const int HOUR_MAX = 4; //Set Hour Max to 4
const int SIZE = 3; //Set Array Size to 6
//local variables
int Count = 0; //Init Count to 0
string Name; //Students Name
float Grade; //Students Grade
int Hours; //Credit Hours
float Pts; //Convert Grade to Pts
float Grade_Array [SIZE]; //Initialize Grade Array
float Hour_Array [SIZE]; //Initialize Hour Array
float Pts_Array [SIZE]; //Initialize Pts Array
float Gpa; //Initialize GPA
float Total_Gradepts; //Total of Grades in Array
float Total_Crdt; //Total of Hrs in Array
/**************************start main program*********************/
// Spaces from top of screen
cout << "\n\n\n\n\n\n";
//Input name or quit value
cout << setw(57) << "Input Students Name Or -1 To Quit" << endl;
cout << "\n\n";
//Input Student Name
cout << setw(48) << "Students Name : ";
cin >> Name;
//WHILE Name does not equal QUIT
while (Name != QUIT_NAME)
{
//Call Function To Input
input (Grade, Hours, Count, Pts, Grade_Array, Hour_Array, Pts_Array);
//Clear Screen
system ("cls");
//Call Function to Calculate GPA
gpa (Total_Gradepts, Pts_Array, Total_Crdt, Hour_Array, Gpa);
//Call Function to Display the grade report
display (Count, SIZE, Grade_Array, Hour_Array, Pts_Array, Gpa);
//Pause Screen
system ("pause");
//Clear Screen
system ("cls");
// Spaces from top of screen
cout << "\n\n\n\n\n\n";
//Input name or quit value
cout << setw(57) << "Input Students Name Or -1 To Quit" << endl;
cout << "\n\n";
//Input Student Name
cout << setw(48) << "Students Name : ";
cin >> Name;
//END WHILE
}
//Call function to display closing message (optional)
close();
//Pause Screen
system ("pause");
}//END Calc Students GPA
|
/********************************************************************
*Function Name : Input
*Author :
*Date : May 12, 2014
*Program Description: This function will ask user for a grade, &
* credit hours, calculate pts, and put all three in separate arrays.
*
*BEGIN Function Grade Input
* Input Grade (0.0-4.0)
* Input Credit Hours (1-4)
* Calculate Pts
* Put Grade, Credit Hours, & Pts. in separate Arrays
*END Function
************************Start Input Function*************************/
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
|
float input (float Grade, float Hours, int Count, float Pts, float Grade_Array[],
float Hour_Array[], float Pts_Array[])
{
//local constant
//local variables
// float Grade; //Students Grade
// float Hours; //Credit Hours
// float Pts; //Convert Grade to Pts
/*************************************************************/
//Input Grade
cout << "\n" << setw(48) << "Students Grade : ";
cin >> Grade;
//Input Credit Hours
cout << setw(48) << "Credit Hours : ";
cin >> Hours;
//Call Function To Validate Input Data
validate (Grade, Hours);
//Calc Grade Pts
Pts = Grade * Hours;
//ADD Grade, Credit Hours, Grade Pts to Array
Grade_Array [Count] = Grade;
Hour_Array [Count] = Hours;
Pts_Array [Count] = Pts;
}
|
/********************************************************************
*Function Name : Validate
*Author :
*Date : May 12, 2014
*Program Description: This function will check to make sure grade &
* credit hours are valid
*
*BEGIN Function Validate
* WHILE (Grade is not QUIT)
* IF (Grade & Credit Hours are Valid)
* Increment Count
* IF (Array if Full)
* Grade = QUIT
* ELSE
* Get Next Grade
* END IF
* ELSE
* Display Error
* Get Next Grade
* END IF
* END WHILE
*END Function
***********************Start Validate Function***********************/
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72
|
bool validate (int Grade, int Hours)
{
//local constant ??
const float GRADE_LOW = 0.0; //Set Grade Low to 0.0
const float GRADE_HIGH = 4.0; //Set Grade High to 4.0
const int HOUR_MIN = 1; //Set Hour Min to 1
const int HOUR_MAX = 4; //Set Hour Max to 4
const int QUIT = -1; //Init Quit Value
const int SIZE = 3; //Set Array Size to 6
//local variables ??
int Count = 0; //Init Count to 0
// float Grade; //Students Grade
// float Hours; //Credit Hours
float Pts; //Convert Grade to Pts
float Grade_Array [SIZE]; //Initialize Grade Array
float Hour_Array [SIZE]; //Initialize Hour Array
float Pts_Array [SIZE]; //Initialize Pts Array
/*************************************************************/
//IF (Grade & Credit Hours are Valid)
if ((Grade >= GRADE_LOW && Grade <= GRADE_HIGH) &&
(Hours >= HOUR_MIN && Hours <= HOUR_MAX))
{
//Calc Grade Pts
//Pts = Grade * Hours;
//ADD Grade, Credit Hours, Grade Pts to Array
//Grade_Array [Count] = Grade;
//Hour_Array [Count] = Hours;
//Pts_Array [Count] = Pts;
//Increment Count
Count ++;
//IF (Array if Full)
if (Count == SIZE)
Grade = QUIT;
//ELSE
else
{
cout << "\n" << setw(48) << "Students Grade : ";
cin >> Grade;
}
//END IF
}
//ELSE
else
{
//Display Error
cout << "\n" << setw(42) << "ERROR" << endl;
cout << setw(42) << "-----" << endl;
//Get Next Grade
cout << "\n" << setw(48) << "Students Grade : ";
cin >> Grade;
}
//END IF
//END FUNCTION
}
|