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
|
#include <iostream>
#include <string>
using namespace std;
double average_standard(double stand_total, double days_worked_par);
double average_one(double one_total, double days_worked_par);
double average_two(double two_total, double days_worked_par);
double average_deluxe(double deluxe_total, double days_worked_par);
double banana_points_func(double stand_average, double one_average, double two_average, double delux_average, double wasted);
string star_rating(double points);
int main()
{
double days_worked;
double stan_choc_numb, one_topping_numb, two_topping_numb, deluxe_numb;
double stan_choc_total = 0;
double one_topping_total = 0;
double two_topping_total= 0;
double delux_total = 0;
double wasted_bans = 0;
int n;
char choice;
do
{
//User input for number of days worked
cout << "Enter the number of days the employee worked: ";
cin >> days_worked;
cout << "\nEnter the amount of each typer for each day worked.\n";
for (n = 1; n <= days_worked; n++)
{
//Getting the number of bananas sold for each day
cout << "Day " << n << endl;
cout << "Standard Chocolate Covered: ";
cin >> stan_choc_numb;
cout << "One-Topping: ";
cin >> one_topping_numb;
cout << "Two-Topping: ";
cin >> two_topping_numb;
cout << "The Deluxe: ";
cin >> deluxe_numb;
//Adding the days numbers to the running total
stan_choc_total = stan_choc_total + stan_choc_numb;
one_topping_total = one_topping_total + one_topping_total;
two_topping_total = two_topping_total + two_topping_numb;
delux_total = delux_total + deluxe_numb;
}
//Getting number of wasted bananas
cout << "Enter the number of wasted bananas: ";
cin >> wasted_bans;
//Calling functions and setting them to variables
double standard_choc_average = average_standard(stan_choc_total, days_worked);
double one_topping_average = average_one(one_topping_total, days_worked);
double two_topping_average = average_two(two_topping_total, days_worked);
double delux_average = average_deluxe(delux_total, days_worked);
double banana_points = banana_points_func(standard_choc_average, one_topping_average, two_topping_average, delux_average, wasted_bans);
//Outputting results to user
cout << "\nAverage Sold Per Day:\n";
cout << "Standard Chocolate Covered: " << standard_choc_average << endl;
cout << "One-Topping: " << one_topping_average << endl;
cout << "Two-Topping: " << two_topping_average << endl;
cout << "The Delux: " << delux_average << endl << endl;
cout << "Banana Points: " << banana_points << endl << endl;
string star_rating(banana_points);
cout << "\n\nIs there another employee to calculate? (y/n): ";
cin >> choice;
}while ((choice != n) || (choice != N))
return 0;
}
double average_standard(double stand_total, double days_worked_par)
{
double average = stand_total / days_worked_par;
return (average);
}
double average_one(double one_total, double days_worked_par)
{
double average = one_total / days_worked_par;
return (average);
}
double average_two(double two_total, double days_worked_par)
{
double average = two_total / days_worked_par;
return (average);
}
double average_deluxe(double deluxe_total, double days_worked_par)
{
double average = deluxe_total / days_worked_par;
return (average);
}
double banana_points_func(double stand_average, double one_average, double two_average, double delux_average, double wasted)
{
double point_total = ((stand_average) + (2 * one_average) + (3 * two_average) + (5 * delux_average) - (4 * wasted));
return (point_total);
}
string star_rating(double points)
{
if (points >= 125)
return "This employee has earned a Five Star rating.";
if else ((points >= 75) && (points < 125))
return "This employee has earned a Four Star rating.";
if else ((points >= 50) && (points < 75))
return "This employee has earned a Three Star rating.";
if else ((points >= 25) && (points < 50))
return "This employee has earned a Two Star rating.";
if else ((points >= 10) && (points < 25))
return "This employee has earned a One Star rating.";
else
return "This employee should be fired.";
}
|