Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

The assignment is to write a C program that creates customers\' bill for a carpe

ID: 3628902 • Letter: T

Question

The assignment is to write a C program that creates customers' bill for a carpet company. For main I have:

#include <my.h>

int main(void)
{
int length,width,area,discount;
double price,cost,charge,laborCharge,installed,amtDiscount,subtotal,amtTax,total;


printf("Enter length in feet: ");
scanf("%d",&length);
printf("Enter width in feet: ");
scanf("%d",&width);
printf("Enter the percentage discount: ");
scanf("%d",&discount);
printf("Enter carpet price per foot: ");
scanf("%lf",&price);


printf("MEASUREMENT ");
printf("Length %4d feet ",length);
printf("Width %4d feet ",width);
printf("Area %4d sq ft ",area);
printf(" CHARGES ");
printf("DESCRIPTION COST/SQ.FT. CHARGE/ROOM ");
printf("----------- ----------- ----------- ");
printf("Carpet %5.2f $%7.2f ",price,charge);
printf("Labor %.2f $%7.2f ",labor,laborCharge);
printf("--------- ");
printf("INSTALLED PRICE $%7.2f ",installed);
printf("Discount %2d%% $%7.2f ",discount,amtDiscount);
printf("--------- ");
printf("SUBTOTAL $%7.2f ",subtotal);
printf("Tax $%7.2f ",amtTax);
printf("TOTAL $%7.2f ",total);

return 0;
]

my.h is my header file h that includes:
#include <stdio.h>
#define LABOR_COST 0.35
#define TAX_RATE .085

void read_data( int* length, int* width, int* customerdiscount,
double* costpersquaregfoot)

void calculate_values( int length, int width, int customerdiscount,
double costpersquarefoot, int* area, double* carpetcharge, double*
laborcharge, double* installpricecharge, double* discountcharge, double*
subtotalcharge, double* taxcharge, double* totalcharge)

void calculate_installedprice( int length, int width, int
customerdiscount, double costpersquarefoot, int* area, double*
carpetcharge, double* laborcharge, double* installedpricecharge)

void calculate_subtotal( double* discountcharge, double*
subtotalcharge, double carpetcharge, double laborcharge)

void calculate_price( double* taxcharge, double* totalcharge, double
subtotalcharge)

void printresults( int lenth, int width, int area, double
carpetcharge, double laborcharge, double installedpricecharge, double
discountcharge, double subtotalcharge, double taxcharge, double
totalcharge)

void printmeasurements( int length, int width, int area)

void printcharges( double carpetcharge, double laborcharge, double
installedpricecharge, double discountcharge, double taxcharge, double
totalcharge)

Now, I am supposed to write 9 .c files. Main.c is one, but the other 8 are the functions. Such as function1.c, function2.c, function3.c, etc... How do I write main with these functions so that main works and what do I write in each respective new .c file for the functions, such as what do i write in function1.c?




Explanation / Answer

Dear, This is fundamental violation of C-language accessing more than one .c from anotehr .c file .Because if it is .c file then you need to have a main method .so for 8 .c file you have 8 main funtions . As you said ,you want to access 8 .c funtions from main funtion of 9 .c file but you are indirectly running 9 main mehods from the execution of 9 .c file. That means .c file single point entry execution.you cannot have more than one main in a c-file directly or indirectly. Here are some solutions for the problem: 1.create 8 funtions in the main c file and access within that c -file 2.Craete a structure and in that strucure create any number of funtions and access with help of structure variable. 3.If it is c plus plus ,then we can create a class and in that class create funtions and access with help of crating an object to class. Hope this would help you.
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote