0

#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
#include<stdarg.h>
int i;
int a;
struct employee
{
char fname[10];
char lname[15];
float hours;
float gsalary;
float nsalary;
float tax;
};

struct employee emp[10];

struct item
{
char iname[15];
float quan;
float ucost;
float tsale;
float itax;
float gct;
};

struct item tem[2000];


struct expenses
{

float lbill;
float wbill;
float ibill;
float tbill;
float texpense;
};

struct expenses exp;


char worker()
{
printf("\n Please enter the first name of the employee\n");
scanf("%s", emp.fname);
printf("\n Please enter the last name of the employee\n");
scanf("%s", emp.lname);
}

char product()
{
printf("\n\n******************Product Informantion*************************");
printf("\n Please enter the name of the item\n");
scanf("%s", tem[a].iname);
}

float sales()
{
float tcal;
tem[a].gct=0.15;
printf("\n Please enter the unit cost of the item\n");
scanf("%f",&tem[a].ucost);
printf("\n Please enter the quantity of the item\n");
scanf("%f",&tem[a].quan);
tem[a].itax=tem[a].ucost*tem[a].gct;
tcal=tem[a].quan*(tem[a].ucost + tem[a].itax);
return tcal;
}

float salary()
{
float cal;
printf("\n How many hours were worked by the employee for the week? \n");
scanf("%f",&emp.hours);
emp.gsalary=emp.hours*600;
emp.tax=.15*emp.gsalary;
cal=emp.gsalary-emp.tax;
return cal;
}
float bill()
{
float sum;
printf("\n\n************************Billing Expense*****************");
printf("\n How much was paid for the light bill? \n");
scanf("%f",&exp.lbill);
printf("\n How much was paid for the water bill? \n");
scanf("%f",&exp.wbill);
printf("\n How much was paid for the internet bill? \n");
scanf("%f",&exp.ibill);
printf("\n How much was paid for the telephone bill? \n");
scanf("%f",&exp.tbill);
sum=exp.lbill+exp.wbill+exp.ibill+exp.tbill;
return sum;
}

main()
{
FILE*empl,*ite;
empl=fopen("Employee.txt","w");
ite=fopen("Item.txt","w");
if (empl==NULL)
{
printf("An Error Has Occured");
exit(0);
}
if (ite==NULL)
{
printf("An Error Has Occured");
exit(0);
}
printf("\nWelcome to Daverin Pharmacy\n");
for(i=1; i<=1; i++)
{
worker();
emp.nsalary= salary();

}
for(a=1; a<=1; a++)
{
product();
tem[a].tsale=sales();
}
exp.texpense=bill();
printf("\n*********************Employee*******************\n");
for(i=1; i<=1; i++)
{
fprintf(empl,"\n*************************************************\n");
fprintf(empl,"\nName: %s %s", emp.fname, emp.lname);
fprintf(empl,"\nHours: %4.2f", emp.hours);
fprintf(empl,"\nGross Salary: %4.2f", emp.gsalary);
fprintf(empl,"\nNet Salary: %4.2f", emp.nsalary);
printf("\n*************************************************\n");
printf("\nName: %s %s", emp.fname, emp.lname);
printf("\nHours: %4.2f", emp.hours);
printf("\nGross Salary: %4.2f", emp.gsalary);
printf("\nNet Salary: %4.2f", emp.nsalary);
}
printf("\n\n******************Item*********************\n");
for(a=1; a<=1; a++)
{
fprintf(ite,"\n\n******************************************\n");
fprintf(ite,"\nItem Name: %s", tem[a].iname);
fprintf(ite,"\nQuantity: %4.2f", tem[a].quan);
fprintf(ite,"\nUnit Cost: %4.2f", tem[a].ucost);
fprintf(ite,"\nTotal Sale: %4.2f", tem[a].tsale);
printf("\n\n******************************************\n");
printf("\nItem Name: %s", tem[a].iname);
printf("\nQuantity: %4.2f", tem[a].quan);
printf("\nUnit Cost: %4.2f", tem[a].ucost);
printf("\nTotal Sale: %4.2f", tem[a].tsale);
}
fprintf(ite,"\nTotal Bills: %4.2f", exp.texpense);


getch();
}

4
Contributors
3
Replies
4
Views
6 Years
Discussion Span
Last Post by geojia
3

No, since you can't follow simple instructions and use [code] [/code] tags.

Plus I don't do homework anymore, I already have my degree.

My favorite line in your code is:

for(i=1; i<=1; i++)

Edited by Momerath: n/a

Votes + Comments
Love that you found a favorite line. haha
Can you help me transcribe my novel onto notebook paper?
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.