#include <stdio.h>
#include <stdlib.h>
int main()
{
// counters
int i;
int j;
int choose = 0;
// amount of students
int n = 3;
// employee No.
int no[10] = {};
// employee name
char name[][10] = {};
// employee age
int age[10] = {};
// employee salary
int salary[10] = {};
// employee over time hours
float hours[10] = {};
// employee bonus
float bonus[10] = {};
// over time rate
float overTimeRate;
// over time amount
float overTimeAmount;
// Option One
void read() {
printf("Enter the amount of employees: ");
scanf("%d", &n);
for(i = 0; i < n; i++) {
printf("Enter student employee no: ");
scanf("%d", &no[i]);
printf("Enter student employee name: ");
scanf("%s", name[i]);
printf("Enter student employee age: ");
scanf("%d", &age[i]);
printf("Enter student employee salary: ");
scanf("%d", &salary[i]);
}
return;
}
// Option Two
void printOut() {
printf("Employee No. Name Age Salary\n");
for(i = 0; i < n; i++) {
printf("%d ", no[i]);
printf("%s ", name[i]);
printf("%d ", age[i]);
printf("%d\n", salary[i]);
}
return;
}
// Option Three
void amount() {
printf("Enter over time rate: ");
scanf("%f", &overTimeRate);
for(i = 0; i < n; i++) {
printf("Enter over time hours for %d: ", no[i]);
scanf("%f", &hours[i]);
}
for(i = 0; i < n; i++) {
printf("Over time amount for %d ", no[i]);
overTimeAmount = hours[i] * overTimeRate;
printf("is %f\n", overTimeAmount);
}
}
// Option Four
void gwBonus() {
for(i = 0; i < n; i++) {
float gw;
float gwb;
gw = hours[i] * overTimeRate + salary[i];
if (gw < 3000) {
gwb = 0;
}
if ((3000 <= gw) && (gw < 4499)) {
gwb = 0.1;
}
if ((4500 <= gw) && (gw < 5999)) {
gwb = 0.15;
}
if (6000 <= gw) {
gwb = 0.25;
}
bonus[i] = gw * gwb;
}
printf("Employee No. Name Gross Wage Bonus\n");
for(i = 0; i < n; i++) {
printf("%d ", no[i]);
printf("%s ", name[i]);
printf("%f\n", bonus[i]);
}
return;
}
while (choose != 5) {
printf("(1) Option One\n");
printf("(2) Option Two\n");
printf("(3) Option Three\n");
printf("(4) Option Four\n");
printf("(5) Exit\n");
scanf("%d", &choose);
if (choose == 1) {
read();
}
if (choose == 2) {
printOut();
}
if (choose == 3) {
amount();
}
if (choose == 4) {
gwBonus();
}
}
return 0;
}http://www.AssignmentExpert.com/
Comments