-
Further Explanation
I posted this problem as a last resort to a problem I have been working on for three weeks.
Here is the problem:
I have to produce a report with the following:
Measurements
Length xxxft
Width xxxft
Area xxxft
Charges
Description Cost/SQ.FT Charge/Room
- - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Carpet xxx.xx $xxxx.xx
Labor 0.35 xxxx.xx
- - - - - - - - - - - -
Installed Price $xxxx.xx
Discount xx.x% xxxx.xx
- - - - - - - - - - - - -
Subtotal $xxxx.xx
Tax xxxx.xx
Total $xxxx.xx
The above is what the report should look like.
The length & width & carpet price are read in from a data file.
The area, carpet price is calculated.
The labor price is given as .35 x area.
Installed price = carpet charge + labor.
Discount would be subtracted after installed price is calculated
After discount is figured, this would give the subtotal.
Apply tax next and that would give the total.
I know this sounds like a lot but I am having problems doing the calculalions using pointer as well as reading (scanf()) and displaying (printf()) the length and width.
I do not know how to approach the problem using pointers and using pointers within a function.
I don't blame anyone if they skip this problem!!!
Thank you for at least looking at it.
I have attached the program that I am working on. All it has is the array portion of the problem that seems to work fine.
-
I assume you know how to use scanf - partly because this is one of those rare examples that actually uses the status result of scanf.
So if the scanf was in main, you would read an integer like so
Code:
int main ( ) {
int length;
scanf( "%i", &length );
printf( "You entered %d\n", length );
}
Now if you want to bury this inside a function, you need to do this.
Code:
void foo ( int *length ) {
scanf ( "%i", length ); // this is already a pointer
printf( "You entered %d\n", *length );
}
int main ( ) {
int length;
foo ( &length ); // pass a pointer
}
So if you prototype initialization, processCustomerRecord to have int *length, and call them from main passing &length (where int length is the declaration), then you should be able to make some progress.