I seem to be having problems I'm not sure what exactly references are used for I'm not sure if I am using them correctly or not. So the objective is to create a program that allows a student to enter his or her score and it determines the score and displays the score entered and the letter grade equivalent to that score. and then create a loop to allow the user to repeat.
#include <iostream> //cout and cin
#include <conio.h> //for getch
usingnamespace std;
//Function prototypes
void PrintGrade(int&);
void GetScore(int&);
char DetermineGrade(int&);
void GetResponse(char);
int main()
{
//Variables
int studentScore; //a number for student score
int userResponse = 'Y'; //respone from user
//Call Functions
GetScore(studentScore); //get a student score
DetermineGrade(studentScore); //determine student score
PrintGrade(studentScore); //display print grade
GetResponse(userResponse); //get response from user
_getch(); //Hold the screen
}
//***************************************************************************
// Definition of function GetScore. *
// The parameter number is a reference to an double. *
// The function asks a user to enter in a score between 0 and 100 inclusive.*
// If the number entered is not within range, an error message will be *
// displayed, and the user will be asked to try again until a valid score is*
// entered. *
//***************************************************************************
void GetScore(int& score) //number representing month
{
//Main Title
cout << "\tLETTER GRADE CALCULATOR\t" << endl
<<"----------------------------------" << endl << endl;
//prompt user to enter a score and read the score
cout << "Enter a score between 0 and 100 inclusive." << endl;
cin >> score;
//Validate Score
while (score < 0 || score > 100)
{
cout << score << " is not between 0 and 100 inclusive.\n";
cout << "Try again. Enter a score between 0 and 100 inclusive" << endl;
cin >> score; //read score
cout << endl;
}
}
//***************************************************************************
// Definition of function DetermineScore.
// The parameter score holds an score between 0 and 100 inclusive, and then
// it assigns the score a letter grade.
//***************************************************************************
char DetermineScore(int score)
{
char grade = 0;
if(score >=85)
grade = 'A';
elseif(score >=70)
grade = 'B';
elseif(score >=60)
grade = 'C';
elseif(score >=50)
grade = 'D';
else
grade = 'F';
return grade;
}
//***************************************************************************
// Definition of function PrintGrade.
// The parameter score holds an score between 0 and 100 inclusive, and then
// displays the score and grade
//***************************************************************************
void PrintGrade(int score,char grade)
{
cout <<"You entered: " << score << endl;
cout <<"grade: " << grade << endl;
}
#include <iostream>
usingnamespace std;
int _tmain(int argc, _TCHAR* argv[])
{
double numericGrade; // Declaring numericGrade Variable for grade percentage input, Using double to support decimal values.
cout << "Please enter the numeric value of your grade,"<< endl << "I will tell you your letter grade: " << endl << endl;
// Prints out message to ask the user to input numeric value
cin >> numericGrade; // User input numeric Value for grade
if (numericGrade < 60) // nested if/else statement, telling the user its grade based on the numeric value inputed
{
cout << endl << "Your grade is a F " << endl << endl;
}
else
{
if (numericGrade < 70)
{
cout << endl << "Your Grade is a D " << endl << endl;
}
else
{
if (numericGrade < 80)
{
cout << endl << "Your grade is a C " << endl << endl;
}
else
{
if (numericGrade < 90)
{
cout << endl << "Your grade is a B " << endl << endl;
}
else
{
if (numericGrade < 100)
{
cout << endl << "Your grade is an A " << endl << endl;
}
else
{
if (numericGrade >= 100)
{
cout << endl << "Congratulations! You have an A + !" << endl << endl;
}
}
}
}
}
}
system("Pause"); // Pauses the program to wait for user to terminate it
return 0;
}