Subscribe to Eric's Blog

## First Program - % to Get a Better Mark

So after a bit of time following some tutorials and studying other people's code, I decided to make something that is useful at least in the slightest.

A buddy of mine asked me to create for him a program that allowed him to type in his current percent in a class, and then figure out how much more he needed in order to get the grades higher. So if I entered in 68, it would print out how much more is needed for a C, B, and an A.

Here are my lines of code:

```#include <iostream>
#include <conio.h>

using namespace std;

/*The program gets Ryan's current percent, figures out what grade he has and how much
more he needs to get to the higher grades. Do not show the grades lower than his own.*/

int main()
{

//getch();
return 0;
}

//F < 60%; D >= 60%; C >= 70%; B >= 80%; A >= 90%
{
int classPercent;

cout << "Hey man, enter in your class % here (-1 to exit): ";
cin >> classPercent;

while(classPercent != -1)
{
if(classPercent < 60){
cout << "\nYou have to get an extra " << gradeD - classPercent << "% to get a D\n";
}
if(classPercent < 70){
cout << "\nYou have to get an extra " << gradeC - classPercent << "% to get a C\n";
}
if(classPercent < 80){
cout << "\nYou have to get an extra " << gradeB - classPercent << "% to get a B\n";
}
if(classPercent < 90){
cout << "\nYou have to get an extra " << gradeA - classPercent << "% to get a A\n\n";
}
cout << "If you wanna try again, do it now (-1 to exit): ";
cin >> classPercent;
}
}

```

Of course this is nothing fancy, just something I wanted to do independently from the structured tutorials I followed. If anybody happens to be reading this, please note that I am always happy to hear criticism about my code.

### 0 Comments On This Entry

There are no Trackbacks for this entry

S M T W T F S
1234567
891011121314
151617181920 21
22232425262728
2930