You should finish the tutorials on this website. What I said wasn't too hard to understand.
OOP - Object Oriented Programming
http://www.cplusplus.com/doc/tutorial/classes/
It is bad practice to have all of your code in the
int main ()
function. So use functions and you could name the functions add,subtract,multiply,divide,etc.
http://www.cplusplus.com/doc/tutorial/functions/
Using
system();
is considered bad practice, as it leaves security bugs in the program. (I had a link, but I can't find it anymore.) Based on the fact that you are using a cmd color changer, I am assuming you are using windows. In that case use:
http://msdn.microsoft.com/en-us/library/windows/desktop/ms686047%28v=vs.85%29.aspx
Here is some code that I wrote, to demonstrate how to use it. (with the help of the forum of course):
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
|
/* include the input/output stream for console */
#include <iostream>
/* include the windows header for windows api functions */
#include <Windows.h>
/* declare a function to change the console window color */
void v_changeConsoleColor(int color)
{
/* get the current handle of the command prompt window */
HANDLE handle = GetStdHandle(STD_OUTPUT_HANDLE);
/* assign the color of the text in the command prompt window */
SetConsoleTextAttribute(handle, color);
}
/* the main entry point */
int main (void)
{
/* output hello world into the command prompt window */
std::cout << "Hello World!" << std::endl;
/* change the color of the window */
v_changeConsoleColor(2);
/* output hello world into the command prompt window */
std::cout << "Hello World Again!" << std::endl;
/* wait for user input */
std::cin.get();
/* return success */
return 0;
}
|
In your code:
1 2 3 4 5
|
do
{
//Code goes here
}
while (choice1 == '1' &&choice1 == '2' &&choice1 == '3' &&choice1 == '4' &&choice1 != '5');
|
Seems like bad practice to me, since you are comparing integers to characters. I would try:
1 2 3 4 5
|
do
{
//Code goes here
}
while (choice >= 1 && choice <= 4)
|
Edit:
The
break;
statement only works in loops such as while, do-while, and for loops.
I'm not trying to be mean, but you asked for our feedback, and now you criticize what we give you.