Firstly, thank you to those who may be able to assist me. I am doing an assignment in which I have to convert numerical grades into letter grades. I am trying to go one step further and create a program that can do the later, but also switch a letter grade to a numerical grade range.
I have made an option to enter 1 or 2 to specify which way they want a grade converted within a loop, but I can not seem to get the program to start at the very top to start all over. Once the user enters a decision the program runs and only stays within that specific decision. It will not allow me to start over and choose a different method.
#include<iostream>
#include"Input_Validation_Extended.h"
usingnamespace std;
int main()
{
//solve the program page 1 of the week 2/3 packet
char LetterGrade = '\0';
double NumericalGrade = '0';
int decision = '0';
/*
The above statement declares the Numerical Grade
This assigns the grade which allows for the computing of the grade into a Letter Grade
*/
while (decision != '3')
{
cout << "Please Specify to run program:\n\n\n" << endl;
cout << "For a letter grade to numerical range, Press 1" << endl;
cout << "For a numerical grade to a letter grade, press 2" << endl;
cout << "\n(***If you would like to cancel, enter a different number***)\n\n" << endl;
decision = validateInt(decision);
/*
The following block allows a user to input a letter grade for a numerical grade range
*/
while (LetterGrade != 'e')
{
if (decision == 1)
{
cout << "\nWhat is your grade? \nPlease enter letter grade!\n\n " << endl;
cout << "[***If you would like to exit, press 'E'***]\n\n\n" << endl;
//********cout << "------------------------------------" << endl;
/*
cin >> LetterGrade; //deleted for validation input
*/
LetterGrade = validateChar(LetterGrade);//replaces the cin << statement & validates data type
//Adding the grade letter a or A
if (LetterGrade == 'A' || LetterGrade == 'a')
{
cout << "Your letter grade entered was " << LetterGrade << " which means your numerical grade must range from 90.00 to 100...\nYou are doing great!\nKeep studying to maintain that A!\n\n";
}
//Adding the grade letter b or B
elseif (LetterGrade == 'B' || LetterGrade == 'b')
{
cout << "Your letter grade entered was " << LetterGrade << " which means your numerical grade must range from 80.00 to 89.99...\nYou are doing well!\nKeep studying for that A!\n\n";
}
//Adding the grade letter c or C
elseif (LetterGrade == 'c' || LetterGrade == 'C')
{
cout << "Your letter grade entered was " << LetterGrade << " which means your numerical grade must range from 70.00 to 79.99...\nYou are doing ok for now!\nInvest more time in studying!\n\n";
}
//Adding the grade letter d or D
elseif (LetterGrade == 'd' || LetterGrade == 'D')
{
cout << "Your letter grade entered was " << LetterGrade << " which means your numerical grade must range from 60.00 to 69.99...\nYou are doing poorly at the moment!\Studying is essential for a better grade!\n\n";
}
//Adding the grade letter f or F
elseif (LetterGrade == 'F' || LetterGrade == 'f')
{
cout << "Your letter grade entered was " << LetterGrade << " which means your numerical grade must be below 60.00...\nYou are doing awful!\Studying is essential for a better grade!\nYou need to invest more time and effort...\n\n";
}
//If program exits
elseif (LetterGrade == 'e' || LetterGrade == 'E')
{
cout << "thank you for using this app! Goodbye!\n";
break;
}
//If entry is not valid
else
{
cout << "\nI'm sorry, I could not determine your grade!\nPlease try again.\n";
}
}
elseif (decision == 2)
{
cout << "\nTo proceed, I need some more information!\n";
NumericalGrade = validateDouble(NumericalGrade);//Validates data input to verify it is indeed a double.
if (NumericalGrade < 60.00)
{
cout << "\nYou have a F, and should attend class more often.\nYou may need to consult with your instructor!\n";
}
elseif (NumericalGrade >= 60 && NumericalGrade <= 64.9999)
{
cout << "\nYou have a 'D-' which is barely passing.....\nI suggest that you speak to your instructor!\n";
}
elseif (NumericalGrade >= 65.00 && NumericalGrade <= 69.999999)
{
cout << "\nYou have a 'D+' which is passing....\nYou may need to speak to your instructor!\n";
}
elseif (NumericalGrade >= 70.00 && NumericalGrade <= 74.999999)
{
cout << "\nYou have a 'C-' which is passing...But could you do better?\nI suggest you make more time to study!\n";
}
elseif (NumericalGrade >= 75.00 && NumericalGrade <= 79.999999)
{
cout << "\nYou have a 'C+' which is fair...\nI suggest you make more time to study!\nPush yourself for that 'B' you deserve!!!\n";
}
elseif (NumericalGrade >= 80.00 && NumericalGrade <= 84.999999)
{
cout << "\nYou have a 'B-' Which is great!\nWith more time to study, you could achieve an 'A'!\n";
}
elseif (NumericalGrade >= 85.00 && NumericalGrade <= 89.999999)
{
cout << "\nYou have a 'B+' and I suggest you make more time to study!\n";
}
elseif (NumericalGrade >= 90.00 && NumericalGrade <= 94.999999)
{
cout << "\nYou have a 'A-' Which is fantastic!\nCan you push yourself to achieve an A+?n/Time to study!n/";
}
elseif (NumericalGrade >= 95.00 && NumericalGrade <= 99.9999)
{
cout << "\nYou have a 'A+' Which is close to perfection!\nCan you push yourself to achieve an A+?\nTime to study!\n";
}
elseif (NumericalGrade == 100)
{
cout << "\nAre you a A.I. or what?!\nI may have found my soul mate!\n";
}
//test
//If program exits
else//default clause
{
cout << "\nSomething went wrong!!!\nHopefully there weren't any sparks...\n";
}
}
//else for decision
else
{
break;
}
}
return 0;//Press Ctrl + F5, yes to run
}
}