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
|
//*****************************************************************************************************
#include <stdafx.h>
#include <iostream>
#include <string>
#include <iomanip>
using namespace std;
//*****************************************************************************************************
void getHour(int hour[], const string names[], const int SIZE);
void getPayRate(float payrate[], const string names[], const int SIZE);
void calcWages(float wages[], float payrate[], int hour[], const int SIZE);
void display (float wages[], const string names[], const int SIZE);
//*****************************************************************************************************
int main()
{
const int SIZE = 7;
int hour[SIZE];
float payrate[SIZE],
wages[SIZE];
const string names[SIZE] = {"John", "Oliver", "Luke", "Henry",
"Lily", "Chloe", "Mike"};
getHour(hour, names, SIZE);
getPayRate(payrate, names, SIZE);
calcWages(wages, payrate, hour, SIZE);
display(wages, names, SIZE);
cin.get();
cin.get();
return 0;
}
//*****************************************************************************************************
//
//*****************************************************************************************************
void getHour(int hour[], const string names[], const int SIZE)
{
const int lowest = 0;
for(int i = 0; i < SIZE; i++)
{
do
{
cout << "Please enter the hours for employee " << names[i] << ": ";
cin >> hour[i];
if(hour[i] < lowest)
cout << "that in not a vaild amount of hours" << endl;
}
while(hour[i] < lowest);
}
cout << "" << endl;
cout << "=========================================" << endl;
}
//*****************************************************************************************************
//
//*****************************************************************************************************
void getPayRate (float payrate[], const string names[], const int SIZE)
{
float low = 7.25;
for(int i = 0; i < SIZE; i++)
{
do
{
cout << "Please enter the pay rate for employee " <<names[i] << ": ";
cin >> payrate[i];
if(payrate[i] < low)
cout << "Pay rate must be higher than " << low << endl;
}
while(payrate[i] < low);
}
cout << "" << endl;
cout << "=========================================" << endl;
}
//******************************************************************************
//
//******************************************************************************
void calcWages (float wages[], float payrate[], int hour[], const int SIZE)
{
for(int i = 0; i < SIZE; i++)
{
wages[i] = payrate[i] * hour[i];
}
}
//******************************************************************************
//
//******************************************************************************
void display (float wages[], const string names[], const int SIZE)
{
cout << "**Wages information for the week: **" << endl;
cout << "" << endl;
for(int i = 0; i < SIZE; i++)
{
cout << names[i] << setw(15) << " $" << showpoint << setprecision(2) << wages[i] << endl;
}
}
|