Professional Documents
Culture Documents
<iostream>
<iomanip>
<fstream>
<string>
<cctype>
<ctime>
<cstdlib>
"Employee.h"
switch (choice)
{
case ONE:
Math();
break;
case 2:
FileProccessing();
break;
case 3:
TEST();
break;
case 4:
EmployeeClass();
break;
case 5:
{cout<<"Are you sure you want to quit? (Y/N): ";
cin>>Quit;}
}
Quit = toupper(Quit);
}while (Quit != 'Y');
}
void Math()
{
int numOne, numTwo, numAnswer, userNum;
char Again;
do
{
system("CLS");
unsigned seed = time(0);
srand(seed);
numOne = 1 + rand() % 300;
numTwo = 1 + rand() % 300;
if (numOne > numTwo)
{
numAnswer = numOne - numTwo;
cout << " !Math Tutor!" << endl;
cout << "\n
" << setw(5) << numOne << endl;
cout << "
-"<< setw(5) << numTwo << endl;
cout << "
------" << endl;
cout << "\nEnter the correct answer: ";
cin >> userNum;
if (userNum == numAnswer)
{
cout << "\nCongratulation!" << endl;
}
else
{
cout << "\nThe correct answer is: " << numAnswer << endl;
}
}
else
{
void FileProccessing()
{
ifstream infile;
int number, totNum=0, numCount=0;
double avg = 0.0;
char Again = 'Y';
do
{
system("CLS");
infile.open("random.txt");
cout<< endl << endl;
cout<< "Using Files--Numeric Processing" << endl;
cout<< "----------------------------------------" << endl;
if (infile)
{
while (infile >> number)
{
cout<<number<<endl;
totNum += number;
numCount += 1;
}
infile.close();
}
else
cout<<"TXT file opening error.";
if (numCount >0)
{
avg = (1.0*totNum)/numCount;
cout<< "----------------------------------------" << endl;
cout<< "The number of numbers: " << numCount << endl;
cout<< "The sum of all the numbers: " << totNum<< endl;
cout<< "The avrage of all the numbers: " << avg << endl;
cout<< "----------------------------------------" << endl;
}
cout<<"\nwould you like to run the project again? (Y/N): ";
cin>>Again;
Again=toupper(Again);
}while (Again != 'N');
}
void TEST()
{
const int SIZE = 4;
const int Student = 5;
const int Grade = 5;
char LetterGrades[Grade] = {'A', 'B', 'C', 'D', 'F'};
string StudentsName[Student];
double Student1[SIZE];
double Student2[SIZE];
double Student3[SIZE];
double Student4[SIZE];
double Student5[SIZE];
int a;
char Again = 'y';
do
{
system("CLS");
Test_Grades(StudentsName, Student, Student1, SIZE, Student2, SIZE, Student3,
SIZE, Student4, SIZE, Student5, SIZE);
for (a = 0; a < Student; a++)
{
cout<<endl<<"\n "<<StudentsName[a]<<"'s";
if (a == 0)
Student_Grade( Student1, SIZE, LetterGrades,
if (a == 1)
Student_Grade( Student2, SIZE, LetterGrades,
if (a == 2)
Student_Grade( Student3, SIZE, LetterGrades,
if (a == 3)
Student_Grade( Student4, SIZE, LetterGrades,
if (a == 4)
Student_Grade( Student5, SIZE, LetterGrades,
Grade);
Grade);
Grade);
Grade);
Grade);
}
cout<<"\nwould you like to run the project again? (Y/N): ";
cin>>Again;
Again=toupper(Again);
}while (Again != 'N');
};
void Test_Grades( string Names[], int SIZE0, double Grades1[], int SIZE1, double
Grades2[], int SIZE2, double Grades3[], int SIZE3, double Grades4[], int SIZE4,
double Grades5[], int SIZE5)
{
int x, y;
for (x = 0; x < SIZE0; x++)
{
if
if
if
if
if
}
}
": ";
": ";
": ";
": ";
": ";
void EmployeeClass()
{
string Holder;
int Holder2;
char Again = 'Y';
do
{
system("CLS");
Employee item1 ("Susan Meyers", 47899, "Accounting", "Vice President");
Employee item2 ("Mark Jones", 39119); // ("IT" ,"Programmer") i made this so
that i could use the Employee(string A, int B) Function
Employee item3; // ("Joy Rogers", 81774, "Manufacturing", "Engineer") i made
this so that i could use the Employee() Function
cout<<endl<<endl<<"=========================================================
=============";
cout<<endl<<setw(20)<<left<<"Name"<<setw(15)<<left<<"ID Number"<<setw(20)<<l
eft<<"Department"<<left<<setw(20)<<left<<"Position";
cout<<endl<<"_______________________________________________________________
_______"<<endl;
cout<<setw(20)<<left<<item1.getName()<<setw(15)<<left<<item1.getIdNum()<<set
w(20)<<left<<item1.getDep()<<setw(20)<<left<<item1.getPos()<<endl;
cout<<setw(20)<<left<<item2.getName()<<setw(15)<<left<<item2.getIdNum()<<set
w(20)<<left<<item2.getDep()<<setw(20)<<left<<item2.getPos()<<endl;
cout<<setw(20)<<left<<item3.getName()<<setw(15)<<left<<item3.getIdNum()<<set
w(20)<<left<<item3.getDep()<<setw(20)<<left<<item3.getPos()<<endl;
cout<<endl<<"===============================================================
======="<<endl;
cout<<endl<<"Enter "<<item2.getName()<<"'s Department (IT): ";
cin>>Holder;
item2.setDep(Holder);
cout<<endl<<"Enter "<<item2.getName()<<"'s Position (Programmer): ";
cin>>Holder;
item2.setPos(Holder);
system("CLS");
cout<<endl<<endl<<"=========================================================
=============";
cout<<endl<<setw(20)<<left<<"Name"<<setw(15)<<left<<"ID Number"<<setw(20)<<l
eft<<"Department"<<left<<setw(20)<<left<<"Position";
cout<<endl<<"_______________________________________________________________
_______"<<endl;
cout<<setw(20)<<left<<item1.getName()<<setw(15)<<left<<item1.getIdNum()<<set
w(20)<<left<<item1.getDep()<<setw(20)<<left<<item1.getPos()<<endl;
cout<<setw(20)<<left<<item2.getName()<<setw(15)<<left<<item2.getIdNum()<<set
w(20)<<left<<item2.getDep()<<setw(20)<<left<<item2.getPos()<<endl;
cout<<setw(20)<<left<<item3.getName()<<setw(15)<<left<<item3.getIdNum()<<set
w(20)<<left<<item3.getDep()<<setw(20)<<left<<item3.getPos()<<endl;
cout<<endl<<"===============================================================
======="<<endl;
cin.ignore();
cout<<endl<<"Enter Employee's Name (Joy Rogers): ";
getline(cin, Holder);
item3.setName(Holder);
cout<<endl<<"Enter Employee's ID Number (81774): ";
cin>>Holder2;
item3.setIdNum(Holder2);
cout<<endl<<"Enter "<<item3.getName()<<"'s Department (Manufacturing): ";
cin>>Holder;
item3.setDep(Holder);
cout<<endl<<"Enter "<<item3.getName()<<"'s Position (Engineer): ";
cin>>Holder;
item3.setPos(Holder);
system("CLS");
cout<<endl<<endl<<"=========================================================
=============";
cout<<endl<<setw(20)<<left<<"Name"<<setw(15)<<left<<"ID Number"<<setw(20)<<l
eft<<"Department"<<left<<setw(20)<<left<<"Position";
cout<<endl<<"_______________________________________________________________
_______"<<endl;
cout<<setw(20)<<left<<item1.getName()<<setw(15)<<left<<item1.getIdNum()<<set
w(20)<<left<<item1.getDep()<<setw(20)<<left<<item1.getPos()<<endl;
cout<<setw(20)<<left<<item2.getName()<<setw(15)<<left<<item2.getIdNum()<<set
w(20)<<left<<item2.getDep()<<setw(20)<<left<<item2.getPos()<<endl;
cout<<setw(20)<<left<<item3.getName()<<setw(15)<<left<<item3.getIdNum()<<set
w(20)<<left<<item3.getDep()<<setw(20)<<left<<item3.getPos()<<endl;
cout<<endl<<"===============================================================
======="<<endl;
cout<<"\nwould you like to run the project again? (Y/N): ";
cin>>Again;
Again = toupper(Again);
}while (Again != 'N');
}