Answer:
The code has been written in C
Step-by-step explanation:
//input libraries fist, the code is in C
#include<stdio.h>
#include<string.h>
void
main ()
{
int years, ch = 1;
float i, s, previous, day, discount, ytd, bef, disct, total, summation = 0, totalb =
0, totala = 0;
char a[10], b[3];
do
{
l1:printf ("Input number of Years Employed");
scanf ("%d", &years);
if (years < 0)
{
printf ("invalid Please Re-Input");
goto l1;
}
l2:printf ("Input Totalal Previousious Purchases Before Discount");
scanf ("%f", &previous);
if (previous < 0)
{
printf ("Previousious Purchases cant be bellow zero");
goto l2;
}
printf ("Input Employee Status");
scanf ("%s", a);
l3:printf ("Input Days Purchase");
scanf ("%f", &day);
if (day < 0)
{
printf ("Purchases Cannot be minor than zero");
goto l3;
}
if (strcmp (a, "MANAGER") == 0)
{
if (previous >= 200)
{
discount = 0;
ytd = previous;
bef = previous;
disct = 0;
total = day;
summation += day;
totalb += day;
totala += day;
}
else
{
if (years >= 1 && years <= 3)
discount = 0.2;
else if (years >= 4 && years <= 6)
discount = 0.24;
else if (years >= 7 && years <= 10)
discount = 0.3;
else if (years >= 11 && years <= 15)
discount = 0.35;
else
discount = 0.4;
ytd = previous * discount;
bef = 200 - ytd;
s = day * discount;
i = (bef - s);
if (i < 0)
{
bef = previous;
disct = bef;
total = day - disct;
summation += total;
totalb += day;
totala += total;
}
else
{
bef = previous;
disct = i;
total = day - disct;
summation += total;
totalb += day;
totala += total;
}
}
}
else
{
if (previous >= 200)
{
discount = 0;
ytd = previous;
bef = previous;
disct = 0;
total = day;
summation += day;
totalb += day;
totala += day;
}
else
{
if (years >= 1 && years <= 3)
discount = 0.1;
else if (years >= 4 && years <= 6)
discount = .14;
else if (years >= 7 && years <= 10)
discount = 0.2;
else if (years >= 11 && years <= 15)
discount = 0.25;
else
discount = 0.3;
ytd = previous * discount;
bef = 200 - ytd;
s = day * discount;
i = (bef - s);
if (i < 0)
{
bef = previous;
disct = bef;
total = day - disct;
summation += total;
totalb += day;
totala += total;
}
else
{
bef = previous;
disct = i;
total = day - disct;
summation += total;
totalb += day;
totala += total;
}
}
}
printf (" Discount =%f\\", discount);
printf ("= YTD=%f\\", ytd);
printf ("Employees Purchase Before Discount=%f\\", bef);
printf ("Employees Discount Day = %f\\", disct);
printf ("Employees Total Purchase=%f\\", total);
printf ("Continue Input YES if OK");
scanf ("%s", b);
if (strcmp (b, "YES") != 0)
ch = -1;
}
while (ch == 1);
printf ("total of Purchases Day = %f\\", summation);
printf ("Total of Before Discounts Day = %f\\", totalb);
printf ("Totalal of Discounts day = %f\\", totala);
}
OUTPUT
Input number of Years Employed2
Input Totalal Previousious Purchases Before Discount3
Input Employee Status4
Input Days Purchase5
Employee Discount =0.100000
Employees YTD=0.300000
Employees Purchase Before Discount=3.000000
Employyes Discount Day = 199.199997
Employees Totalal Purchase=-194.199997
Do you Wish to Continue Input YES if OK