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 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345
|
#include<iostream>
#include<math.h>
#include<iomanip> // needed for the setpresion manipulator
#include <string>
#include <vector>
#include <math.h>
#include <algorithm>
#include <conio.h>
#include <numeric>
using namespace std;
void displayWelcomeMessege()
{
//change text color to bright white. just to see better. F for FUN Learning!!
std::system("COLOR F");
std::cout<<"Earning statement Mod. To complete this module you will need the following information:\n \n\t\t\tEmployee number \n\t\t\tHours worked \n\t\t\tPay rate \n\t\t\tUnion code\n"<< "\tPlease enter the employee number.\n";
}
void begin( vector<string>Names, vector<double>Hours, vector<double>Fedtax, vector<double>Payrate, vector<double>Uniondues, vector<char>Union, string EmID,double hoursworked, double payrate,char code, int i ,double hours , double regpay, double grosspay, vector<double>Gross,
vector<double>Overtime,vector<double>RegPay,float dues,vector<double>Netpay, double overtimepay, double fedtax)
{
for (int i=0; i<5; i++)
{
void getInput();
double Code ( char code);
double Grosspay( vector<double>Hours, vector<double>Payrate, double hoursworked, double payrate);
double Fedtax (double grosspay);
double Netpay(double grosspay, double fedtax, double dues,vector<double>Netpay);
}
void displaypayrollinfo (vector<string>Names, vector<double>Hours, vector<double>Payrate, vector<double>Uniondues, vector<char>Union,
vector<double>Overtime,vector<double>RegPay,float dues,vector<double>Netpay);
void TerminationMessege ();
}
void getInput ( vector<string>Names, vector<double>Hours, vector<double>Payrate, vector<char>Union,string EmID,double hoursworked, double payrate,char code, int i)
{
// output needed information and display it until the first entry
std::cout<<"\t Input Employee ID. \n";
// input employee's employment number
std::cin>> EmID;
Names.push_back(EmID);
// request the total hours worked
std::cout<< "\n Please enter the total hours worked for employee \n";
// input the total hours worked
std::cin>> hoursworked;
Hours.push_back(hoursworked);
//request employee's earning wage information
std::cout<<"\nEnter the pay rate for \n";
// input payrate for requested employee
std::cin>>payrate;
Payrate.push_back(payrate);
// request the employee's union information
std::cout<<"\n Enter the applicable Union Code, A,B or C, for employee \n";
// inputs the union character data
std::cin>>code;
}
double Code( vector<double>Uniondues, vector<char>Union,char code, float dues)
{
while(code!='A' &&
code!='a' && // while loop to define nessesary conditions
code!='B' &&
code!='b' &&
code!='C' &&
code!='c')
{
std::cout<<" Inputted union code is invalid.\n"; // if conditions invalid output cout<<
std::cout<<" Enter valid Union Code\n";
std::cin>>code; // then ask and cin>> correct input
}
switch (code) //switch statement to assign dues to the accepted Union code
{
case 'A': case 'a':
dues= 25.00;
break; //breaks allow the next case to be ran if prev case fail
case 'B' : case 'b':
dues= 50.00;
break;
case 'C' : case 'c':
dues= 75.00;
break;
default:break; // uses break as a default since values were checked in while loop
}
Union.push_back(code);
Uniondues.push_back(dues);
return code, dues;
}
void Grosspay( double hours , double regpay, double payrate, double grosspay, vector<double>Gross, double overtimepay,
vector<double>Overtime,vector<double>RegPay)
{
if
// if true hoursworked is less or equal to 40
(hours <= 40)
// regpay will equal the number of hours worked times the payrate
{
regpay = (hours * payrate);
overtimepay=0;
}
// if true hoursworked is greater than 40
if (hours > 40)
// regpay is (40) times pay rate
{
regpay = ((40)* payrate);
overtimepay = (1.5*(hours-40)* payrate);
}
//gross pay = regualar pay plus any overtime pay.
grosspay = ( regpay + overtimepay);
Gross.push_back(grosspay);
Overtime.push_back(overtimepay);
RegPay.push_back(regpay);
}
double Fedtax(double grosspay, vector<double>Gross, double overtimepay, double fedtax, double regpay,
vector<double>Overtime,vector<double>RegPay,float dues,vector<double>Netpay,vector<double>Fedtax)
{
//if gross pay is greater than 2000
if (grosspay > 2000)
// federal tax rate is 25% of the gross pay
{
fedtax = (0.25*grosspay);
}
//if gross pay is more than $1000 and lss than or equal to $2000
if (grosspay > 1000 && grosspay<= 2000)
// then federal tax rate is 15% of the gross pay
{
fedtax =( 0.15*grosspay);
}
// declares alternative for all other values not listed
else
// then federal tax rate is 10% of the gross pay
{
fedtax = (0.10 * grosspay);
}
Fedtax.push_back(fedtax);
Gross.push_back(grosspay);
Overtime.push_back(overtimepay);
RegPay.push_back(regpay);
return (fedtax,grosspay,regpay,overtimepay);
}
double Netpay(double grosspay, double fedtax, double dues, double netpay, vector<double>Netpay)
{
netpay = (grosspay - (fedtax + dues));
Netpay.push_back(netpay);
return netpay;
}
int main()
{
displayWelcomeMessege();
void begin ( string EmID,double hoursworked, double payrate,char code, int i ,double hours , double regpay, double grosspay, float dues, double overtimepay, double fedtax);
void TerminationMessege ();
system ("pause");
return 0;
}
void displaypayrollinfo ( vector<string>Names, vector<double>Hours, vector<double>Fedtax, vector<double>Payrate, vector<double>Uniondues, vector<char>Union, string EmID,double hoursworked, double payrate,char code, int i ,double hours , double regpay, double grosspay, vector<double>Gross,
vector<double>Overtime,vector<double>RegPay,float dues,vector<double>Netpay, double overtimepay, double fedtax)
{
//preforms data reveiw of the (unioncode) to select and attach appropriate union fee
//fixed sets the output to decimal instead of scientific notaion and // Caluates results are formatted to two decimal places by setprecision(2).
std::cout<<fixed<<setprecision(2);
// Output statements to display input data and calculation results
// Caluated results are formatted to two decimal places by setprecision(2).
for (int i=0; i<5; i++)
{
std::cout<< "Employee: "<<Names[i]<< " "<< "Hours: "<< Hours[i]<< " "<< "Pay rate: "<< Payrate[i]<< " "<<"Union code: "<<Union[i]<<"\n\n";
std::cout<< "\t\tRegular pay: "<<RegPay[i]<< "\n\n";
std::cout<< "\t\tOvertime pay: "<<Overtime[i]<<"\n\n";
std::cout<<"\t\tGross pay: "<<Gross[i]<<"\n\n";
std::cout<<"\t\tFederal tax: "<<Fedtax[i]<<"\n\n";
std::cout<< "\t\tUnion dues: "<<Uniondues[i]<<"\n\n";
std::cout<< "\t\tNet pay: "<<Netpay[i]<<"\n\n";
}}
void TerminationMessege (void)
{
// The output statement to display an appropriate end-of-program message.
cout<< "\t\t\t This program is for training purposes only.\n \t\t\t\t Have a nice day...";
}
|