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
|
#include<stdio.h>
#include<stdarg.h>
#include<string.h>
#include<stdlib.h>
int quantity, sandwichtotal, milkshaketotal, cheesecaketotal, total,
age, totalreview, rate, emppay, review, hours, sales, i, a;
int highest = 0;
float totalcost, totalsold, payrate, tax;
float gpay[5];
float npay[5];
struct empdata
{
char fname[10];
char lname[10];
int age; // A structure is created to store the data of \
three employees
char gender[6];
char DOB[20];
char address[15];
int hours;
int sales;
} des[3];
struct sandwiches
{
char name[8];
int quantity; // A structure is created to store the data of \
three types of sandwiches sold by the business
} ham, chicken, tuna;
struct milkshakes
{
char name[10];
int quantity;
} chocolate, vanilla, strawberry; // A structure is created to store the \
data of three types of milkshakes sold by the business
struct cheesecake
{
char name[10];
int quantity; // A structure is created to store the data of \
two types of cheesecake sold by the business
} cherry, blueberry;
float
Payroll()
{
for (i = 0; i < 3; i++) {
printf("Please enter first name \n");
scanf("%s", des[i].fname);
printf("Please enter last name \n");
scanf("%s", des[i].lname);
printf("Please enter age \n"); //Option 1. Employees enter th\
eir data
scanf("%d", &des[i].age);
printf("Please enter gender \n");
scanf("%s", des[i].gender);
printf("Please enter Date of Birth separated by forward slashes \n");
scanf("%s", des[i].DOB);
printf("Please enter your address separated by underscores \n");
scanf("%s", des[i].address);
printf("Please enter the amount of sales received \n");
scanf("%d", &des[i].sales);
tax = 0.08;
printf("Please enter the amount of hours worked \n"); // A sub-functi\
on is created to calculate the payroll of each employee
scanf("%d", &hours);
printf("Please enter your payrate \n");
scanf("%f", &payrate);
gpay[i] = des[i].hours * payrate;
npay[i] = gpay[i] - (gpay[i] * tax);
return npay[i];
}
}
void
Goodemployee() // dmh
{
if (sales > highest) { // A sub-function is created t\
o calculate the highest saes made by employees. This employee would be the empl\
oyee of the month
highest = sales;
}
}
int
main()
{
int i;
int code;
FILE *fp;
fp = fopen("Desiire.dat", "a+"); // A file is created
printf("\n --------------------------------------------------------- \n");
printf("\n WELCOME TO DESIRE'S NETWORK \n");
printf("\n ----------------------------------------------------------\n");
printf("If you are an employee entering records, please type 1 \n"); \
// List of options for user to select
printf("If you are a customer who wishes to leave a rate, please type 2 \n"\
);
printf("If you are a customer placing an order, please type 3 \n");
printf("If you wish to exit the program, please type 4 \n");
scanf("%d", &code);
system("cls");
switch (code) {
case 1:
Payroll(); // The sub-function is called
fprintf(fp, "%s %s \n", des[i].fname, des[i].lname);
fprintf(fp, " %d \n", des[i].age);
fprintf(fp, " %s \n", des[i].gender);
fprintf(fp, " %s \n", des[i].DOB);
fprintf(fp, " %s \n", des[i].address); // The output is stored in the\
file
fprintf(fp, " %d \n", des[i].sales);
fprintf(fp, " %.2f \n", npay[i]);
Goodemployee(); // A sub-function is called
break;
#if 0
case 2:
Customer(); // A sub-function is called
fprintf(fp, "The amount of reviews made are %d", totalreview);
break;
case 3:
fprintf(fp, "The amount of ham sandwiches sold is %d \n", ham.quantity)\
;
fprintf(fp, "The amount of chicken sandwiches sold is %d \n", chicken.q\
uantity);
fprintf(fp, "The amount of tuna sandwiches sold is %d \n", tuna.quantit\
y);
fprintf(fp, "The total amount of sanwiches bought is %d \n", sandwichto\
tal);
fprintf(fp, "The amount of chocolate milkshakes sold is %d \n",
chocolate.quantity);
fprintf(fp, "The amount of vanilla milkshakes sold is %d \n", vanilla.q\
uantity);
fprintf(fp, "The amount of strawberry milkshakes sold is %d \n", strawb\
erry.quantity); // The output is stored in the file
fprintf(fp, "The total amount of milkshakes bought is %d \n", milkshake\
total);
fprintf(fp, "The amount of cherry cheesecakes sold is %d \n", cherry.qu\
antity);
fprintf(fp, "The amount of blueberry cheesecake sold is %d \n ",
blueberry.quantity);
fprintf(fp, "\n");
Itemssold(); // A sub-function is called
MonthlyReport(); // A sub-function is called
fprintf(fp, "The total of stock sold is %d \n", totalsold);
fprintf(fp, "The total of the employee's pay is %.2f \n", totalcost);
system("cls");
break;
case 4:
exit(0);
break;
#endif
default:
printf(" The option you entered is unavailable");
}
}
|