Subscribe to Eric's Blog        RSS Feed
-----

First Program - % to Get a Better Mark

Icon Leave Comment
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.*/

void gradeAverage();

int main()
{
    gradeAverage();

    //getch();
    return 0;
}

//calculates the grade average
//F < 60%; D >= 60%; C >= 70%; B >= 80%; A >= 90%
void gradeAverage()
{
    int classPercent;
    int gradeD = 60;
    int gradeC = 70;
    int gradeB = 80;
    int gradeA = 90;

    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

 

Trackbacks for this entry [ Trackback URL ]

There are no Trackbacks for this entry

November 2014

S M T W T F S
      1
2345678
9101112131415
161718192021 22
23242526272829
30      

Tags

    Recent Entries

    Search My Blog

    0 user(s) viewing

    0 Guests
    0 member(s)
    0 anonymous member(s)

    Categories