Here is how I might have formatted your program:
Code:
#include<iostream>
#include<string>
#include<limits>
using namespace std;
int response = 0;
int main()
{
//Main screen
cout << " +++++++++++++++++++++++++++++++++++++++++++++++++++++ " << endl;
cout << " + Welcome to Tire Utility + " << endl;
cout << " + Made by Fernando Balandran V1.0 + " << endl;
cout << " + + " << endl;
cout << " + + " << endl;
cout << " + Press 1 for Menu + " << endl;
cout << " + Press 6 to quit program + " << endl;
cout << " +++++++++++++++++++++++++++++++++++++++++++++++++++++ " << endl;
//Checks the input and clears cin
bool quit2 = false;
do
{
cin >> response;
cin.clear();
cin.ignore(numeric_limits<streamsize>::max(), '\n');
if (response == 1)
{
cout << "Loading....." << endl;
quit2 = true;
break;
}
if (response == 6)
{
break;
}
else
{
cout << "Invalid input. Try again: " <<endl;
}
}
while(!quit2);
bool quit = false;
do
{
if (response == 1)
{
cout << " Press 1 to Return to Main Menu " << endl;
cout << " Press 2 for Reach " << endl;
cout << " Press 3 for Pacer " << endl;
cout << " Press 4 for Transport " << endl;
cout << " Press 5 for Order Picker " << endl;
cout << " Press 6 to quit program " << endl;
bool quit2 = false;
do
{
cin >> response;
cin.clear();
cin.ignore(numeric_limits<streamsize>::max(), '\n');
if (response <= 5)
{
cout << "Loading....." <<endl;
quit2 = true;
break;
}
if (response == 6)
{
quit2 = true;
}
else
{
cout << "Invalid input. Try again: " <<endl;
}
}
while (!quit2);
}
if (response == 2)
{
cout << " Reach Truck Tires and Bearings " << endl;
cout << endl;
cout << " Load Wheel.......................632052GB" << endl;
cout << " >>Load Wheel Bearing .......441-130" << endl;
cout << " Steered Idler Wheel..............632-078/007" << endl;
cout << " >>Bearing(Steered Idler)....44-128" << endl;
cout << " Drive Wheel Assy.................828-003-339/101" <<endl;
cout << " >>Drive Tire only ..........632-131/001" << endl;
cout << " >>Hub, Drive Wheel..........828-003-073" << endl;
cout << endl;
cout << " Main menu 1 or 6 to quit program" << endl;
bool quit2 = false;
do
{
cin >> response;
cin.clear();
cin.ignore(numeric_limits<streamsize>::max(), '\n');
if (response == 1)
{
cout << "Loading....." <<endl;
quit2 = true;
break;
}
if (response == 6)
{
break;
}
else
{
cout << "Invalid input. Try again: " <<endl;
}
}
while (!quit2);
}
if (response == 3)
{
cout << " Pacer Drive Wheel" << endl;
cout << " >>Tire, Rubber, Black, Standard......630-259/001"<<endl;
cout << " >>Wheel, Hub.........................223-001-153/002" <<endl;
cout << " >>Bolt, Tire, Drive..................828-004-578" << endl;
cout << endl;
cout << " Steering Wheel" << endl;
cout << " >>Tire Black.........................632-099/002" <<endl;
cout << " >>Hub, Machine.......................123-000-586"<< endl;
cout << " >>Bearing, Cup.......................447-561"<< endl;
cout << " >>Bearing, Roller....................447-085"<< endl;
cout << " >>Seal...............................530-615"<< endl;
cout << endl;
cout << " Main menu 1 or 6 to quit program" << endl;
bool quit2 = false;
do
{
cin >> response;
cin.clear();
cin.ignore(numeric_limits<streamsize>::max(), '\n');
if (response == 1)
{
cout << "Loading....." <<endl;
quit2 = true;
break;
}
if (response == 6)
{
break;
}
else
{
cout << "Invalid input. Try again: " <<endl;
}
}
while (!quit2);
}
if (response == 4)
{
cout << " Transport Drive Wheel" << endl;
cout << " >>Tire, Rubber, Black, Standard......1063760/001"<<endl;
cout << " >>Wheel, Hub.........................1058946" <<endl;
cout << endl;
cout << " Load Wheels" << endl;
cout << " 3 Wheel Kit...............................939-WHL/KITGL" <<endl;
cout << endl;
cout << " Split Wheel...............................632-076/007"<< endl;
cout << " >>Bearing, Roller....................441-127"<< endl;
cout << endl;
cout << " Single Wheel..............................632069GB"<< endl;
cout << " >>Bearing, Roller....................441-127" <<endl;
cout << endl;
cout << " Caster Assy...............................1019920" <<endl;
cout << " >>Wheel..............................632421GB" << endl;
cout << " Main menu 1 or 6 to quit program" << endl;
bool quit2 = false;
do
{
cin >> response;
cin.clear();
cin.ignore(numeric_limits<streamsize>::max(), '\n');
if (response == 1)
{
cout << "Loading....." <<endl;
quit2 = true;
break;
}
if (response == 6)
{
break;
}
else
{
cout << "Invalid input. Try again: " <<endl;
}
}
while (!quit2);
}
if (response == 5)
{
cout << " Order Picker Wheels" << endl;
cout << " >>Drive Wheel........................114-018-513/001"<<endl;
cout << endl;
cout << " Load Wheel" << endl;
cout << " >>Wheel, Poly........................632-156/003" << endl;
cout << " >>Bearing, Ball......................441-30"<< endl;
cout << " Main menu 1 or 6 to quit program" << endl;
bool quit2 = false;
do
{
cin >> response;
cin.clear();
cin.ignore(numeric_limits<streamsize>::max(), '\n');
if (response == 1)
{
cout << "Loading....." <<endl;
quit2 = true;
break;
}
if (response == 6)
{
break;
}
else
{
cout << "Invalid input. Try again: " <<endl;
}
}
while(!quit2);
}
if (response == 6)
{
cout << "Exiting program........";
quit = true;
}
}
while (!quit);
}
My observations:
- There is no reason for response is a global variable; prefer local variables and pass them around if needed.
- Your global main function is well over 250 lines, even after I removed some extra blank lines; functions should do one thing and do it well.
- You have code that is repeated time and time again with what looks like copy and paste; this is crying out loud to be moved into a function or otherwise re-arranged.
- Avoid magic numbers. We can see what those numbers mean from the menu text, but when the menu text is way before the places where these numbers are used, it becomes more difficult to understand what is what. Using named constants would help.
- Your excessive use of endl is not necessarily wrong, but you don't really need to flush the output buffer all the time. Just use '\n' and reserve endl to when you want to print a newline and flush the output buffer.
EDIT:
On that last point, here is an example, where this:
Code:
cout << " Reach Truck Tires and Bearings " << endl;
cout << endl;
cout << " Load Wheel.......................632052GB" << endl;
cout << " >>Load Wheel Bearing .......441-130" << endl;
cout << " Steered Idler Wheel..............632-078/007" << endl;
cout << " >>Bearing(Steered Idler)....44-128" << endl;
cout << " Drive Wheel Assy.................828-003-339/101" <<endl;
cout << " >>Drive Tire only ..........632-131/001" << endl;
cout << " >>Hub, Drive Wheel..........828-003-073" << endl;
cout << endl;
cout << " Main menu 1 or 6 to quit program" << endl;
could become:
Code:
cout << " Reach Truck Tires and Bearings\n\n"
" Load Wheel.......................632052GB\n"
" >>Load Wheel Bearing .......441-130\n"
" Steered Idler Wheel..............632-078/007\n"
" >>Bearing(Steered Idler)....44-128\n"
" Drive Wheel Assy.................828-003-339/101\n"
" >>Drive Tire only ..........632-131/001\n"
" >>Hub, Drive Wheel..........828-003-073\n\n"
" Main menu 1 or 6 to quit program"
<< endl;