Average Calculator-Dev-C++

ShawnCplus 0 Tallied Votes 871 Views Share

This is the first program I wrote, well besides Hello world. I put about a lot of hours into this code, it started as a divisional calculator than i evolved it so it would ask your name and calculate your average and i was messing around with the system ("") code to manipulate it to change the text and background color, you can change it if you want just go Start>Run>cmd>help colors> then where the colors are enter it in the system("color blah") well hope it works and i hope you like it

/***********************************************************\
|  Name: Average Calculater                                 |
|  Author: Shawn .aka. ShawnCplus                           |
|  Date: 05/04/05 21:01                                     |
|  Description: Program that takes the input from 5 grades, |
|  averages them, then evaluates them (taken from           |
|  Gradeapp.cpp prog). It then gives a menu to quit or      |
|  repeat the program, the code takes advantage of the      |
|  system function to start the evaluater program and change|
|  the color and title of the program.                      | 
\***********************************************************/

#include <iostream>

using namespace std; 

int main()
{
    char name [100];
	char quit;
    quit ='\0';
    while (quit !='q')
    { 
        system("title Average Calculator");
        system("color 84");
		 int a, b, c, d, e, x, z; //loads integers into memory
cout <<"This is a simple average calculator. Just put in your 5 most important grades"<< endl;
cout<<"What is your name?"<< endl;
cin.getline (name,100);
cout<<"Hello, " << name << "."<<  endl;
cout<<"Put in your first grade:"<< endl; //asks for grade
cin>> a; //Receives grade and loads it into memory
cout<<"Put in your second grade:"<< endl; 
cin>> b;
cout<<"Put in your third grade:"<< endl;
cin>> c;
cout<<"Put in your fourth grade:"<< endl;
cin>> d;
cout<<"Finally, enter your last grade:"<< endl;
cin>> e;
z = a+b+c+d+e; //makes z integer equal to all grades added together (starting division equation)
x = z; //makes the x integer equal to z (to make me less frustrated) 
if (x/5<=65) //Starting exceptions
{
            cout<<"Are you even trying to do you're work!?"<< endl;
            }
            else if (x/5==75)
            {
                 cout<<"Try to pick up the pace a little bit."<< endl;
                 }
                 else if (x/5==80)
            {
                 cout<<"You are doing a decent job at keeping the grades up."<< endl;
                 }
                 else if (x/5==90)
                 {
                      cout<<"You're doing a great job, keep it up"<< endl;
                      }
                      else if (x/5>=95)
                      {
                           cout<<"Hmph. Teachers pet."<< endl; //End Exceptions
                           }
cout<<"Your average is " << x/5 << ".\a"<< endl; //Outputs final divisional answer (all grades/5)
cout<<""<< endl;
cout<<"Q - Quit"<< endl;
cout<<"R - Repeat"<< endl;
cout<<"Please type in the corresponding letter for your choice then press enter."<< endl;
cin>> quit;
cout<<"Goodbye, " << name << "."<< endl;
system("PAUSE");
system("cls");
}

return 0;
}
/*****************************\
|        To-Do List           |
| 1. Add A Few Easter Eggs    |
| 2. Get Better At Coding     |
| 3. Add more to To-Do List   |
\*****************************/
ShawnCplus 456 Code Monkey Team Colleague

Sorry for all the comments most of them are for me so incase i get stupid and forget one of those lines, a little mental
helper, and yes before anyone asks and wastes a post i am in school why else would i make this :)

ShawnCplus 456 Code Monkey Team Colleague

I have a little question in my line of code that asks for a name how do i add an exception for the name like if (name==blah) it tells me that blah is undefined.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.