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 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219
|
#include <iostream>
#include <string>
#include <fstream>
#include <iomanip>
using namespace std;
void welcome()
{
system("cls");
cout << "Welcome from Networks For You, please have your information ready for the invoice\n";
}
class Process;
{
public:
float hoursWorked;
double payRate;
double teamMemberAmmount
double invoiceTotal
double process(float hoursWorked, double payRate)
{
teamMemberAmmount = (hoursWorked * payRate);
invoiceTotal = invoiceTotal + teamMemberAmmount;
invoiceNumber = rand() % 99999 + 9999; // generate a random number for the invoice number
}
};
class Input;
{
public:
string titleName
string clientName
string teamMemberName
char titleNameSelection
char userResponce
float hoursWorked
double payRate
void input(string clientName, char userResponce, string teamMemberName, char titleNameSelection, string titleName, double payRate, float hoursWorked, double teamMemberAmmount, double invoiceTotal)
};
void input(string clientName, char userResponce, string teamMemberName, char titleNameSelection, string titleName, double payRate, float hoursWorked, double teamMemberAmmount, double invoiceTotal)
{
ofstream outputFile; //open the file outside the loop to let the user finish all the input and entering the data to the file as they put it in
outputFile.open("AndrewSmithProjectThreeInput.txt");
while(userResponce != 'D' )
{
cout << "\nPlease enter your clients name: " ;
cin.clear();// using some cin clears beacuse the program was skipping some inputs
getline (cin,clientName);
cout << "\nThank you " << clientName << " Now please have your team member information ready!\n";
cout << "OK lets get started! \n" << endl;
cin.clear();
userResponce = 'Y'; // this keeps the loop going after the user enthers in the first client
while (userResponce != 'N' && userResponce != 'D' )
{
cout << "Please enter the team member's name: ";
cin.clear();
getline (cin,teamMemberName);// still need to add the not null validation
cout << "\nThank you!\n" << endl;
cout << "Now please select the team member " << teamMemberName << "'s job title from the following" << endl;
cout << "Type A: for Project Manager" << endl;
cout << "Type B: for Network Administrator" << endl;
cout << "Type C: for Network Analyst" << endl;
cout << "Type D: for Network Design Engineer" << endl;
cin >> titleNameSelection;
while(titleNameSelection != 'A' && titleNameSelection != 'B' && titleNameSelection != 'C' && titleNameSelection != 'D')
{
cout << "\nInvalid input please enter A or B or C or D then press enter!\n";
cin >> titleNameSelection;
}
switch(titleNameSelection)
{
case 'A':titleName = "Project Manager";
payRate = 125.00;
break;
case 'B':titleName= "Network Administrator";
payRate = 80.00;
break;
case 'C':titleName = "Project Manager";
payRate= 50.00;
break;
case 'D':titleName = "Network Design Engineer";
payRate = 55.00;
break;
}
cout << "\nPlease enter the amount of hours " << teamMemberName <<" worked. Then press enter: " ;
cin >> hoursWorked;
if (isalpha(hoursWorked))
{
cout << "Invalid input please enter a number" << endl;
cin >> hoursWorked;
cin.clear();
cin.ignore(10000,'\n');
}
while(hoursWorked < 0 || hoursWorked > 300)
{
cout << "Invalid input please enter the amount of hours "<< teamMemberName << " Worked" << endl;
cin >> hoursWorked;
}
cout << "\n********" << endl;
cout << "**Menu**" << endl;
cout << "********" << endl;
cout << "Please type in one of the following choices then press enter" << endl;
cout << "Y- To enter another team member to this client" << endl;
cout << "N- To start a new cliet invoice" << endl;
cout << "D- To finish and print" << endl;
//If you have another team member you would like to enter type Y and press enter \nIf you would like to move onto the next client type in N then press enter. \nIf you are completly done type in D and we will finish up!: ";
cin >> userResponce;
while(userResponce != 'Y' && userResponce != 'N' && userResponce != 'D')
{
cout << "Invalid input please enter Y for another team member N for next client and D to finish capitalized then press enter.\n ";
cin >> userResponce;
}
Process;
if(::count == 1)
{
outputFile << clientName << endl; //sending the data the user just entered to the output file
outputFile << "Invoice Number: " << invoiceNumber << "\n\n";
outputFile << left << setw(19) <<"Team Member Name:" << right << "|" << left << setw(25) << "Title:" << right << "|" << left << setw(7) << "Hours:" << right << "|" << left << setw(15) << "Hourly Rate:" << right << "|" << left << setw(18) << "Team Member Amount:" << endl;
::count = ::count + 1;
}
outputFile << left << setw(19) << teamMemberName << right << "|" << left << setw(25) << titleName << right << "|" << left << "$" << setw(7) << hoursWorked << right << "|" << left << "$" << setw(14) << payRate << right << "|" << left << "$" << setw(18) << teamMemberAmmount << endl;
if(userResponce == 'N' || userResponce == 'D' )
{
outputFile << "\nTotal $" << invoiceTotal << endl;
}
if(userResponce == 'N')// a statement that will add the invoice titles if the user starts a new client
{
::count = 1;
}
cin.clear();
cin.ignore(10000,'\n');
system("cls");
}
outputFile << "\n\n";
}
outputFile.close();
} system("cls");
void output()
{
string nextLine = "";
ifstream inputFile;
inputFile.open("AndrewSmithProjectThreeInput.txt");
while (getline(inputFile, nextLine))//output the entire file to the prompt
{
cout << nextLine << endl;
}
}
int main()
{
srand(time(0));
welcome();
Input;
system("cls");
output();
}
|