Code:
#include "stdio.h"
#include "stdlib.h
#define FILENAME "db.txt"
#define RECEIPT_FILE "receipt.txt"
#define TAXRATE 0.065
int Lookup_Item_Quantity(FILE *db, int item);
double Lookup_Item_Price(FILE *db, int item);
char Lookup_Item_Taxability(FILE *db, int item);
double Compute_Tax(FILE *db, int item, int qty);
int Remove_Qty_From_Inventory(FILE *db, int item, int qty);
int Create_Receipt(FILE *db, int items[][2], int itemcnt);
main() {
int Q;
double price;
char tax;
FILE*db;
db=fopen("db.txt", "r+");
Q=Lookup_Item_Quantity(db, 333333);
printf("%i", Q);
FILE*db;
db=fopen("db.txt", "r+");
Price=Lookup_Item_Price(db, 333333);
printf("%lf", price);
FILE*db;
db=fopen("db.txt","r+");
tax=Lookup_Item_Taxability(db, 333333);
printf("%c", tax);
FILE*db;
db=fopen("db.txt", "r+");
ComputeT=Compute_Tax(db, 33333);
printf("%i", "%lf", Q,Item);
} // end of main()
int Remove_Qty_From_Inventory(FILE *db, int item, int qty){
int rval=1;
FILE *db2 = fopen("temp.txt", "w");
// ...
// YOUR CODE GOES HERE...
// Copy everything over from the db.txt file
// over to the temp.txt file -- be sure to
// subtract qty from the proper item
// ...
// This code renames the temporary file
// to be the new database file
fclose(db);
fclose(db2);
remove(FILENAME);
rename("temp.txt", FILENAME);
db = fopen(FILENAME, "r+");
return rval;
} // end of Remove_Qty_From_Inventory()
int Lookup_Item_Quantity(FILE *db, int item){
while (in !=item){
fscanf(db, "%i", &in);
fscanf(db,"%lf\n" &price);
fscanf(db, "%c", &tax);
fscanf(db, "%i", &Q);
}//end of while
return Q;
} // end of Lookup_Item_Quantity()
double Lookup_Item_Price(FILE *db, int item){
while (in !=item){
fscanf(db, "%i", &in);
fscanf(db,"%lf\n" &price);
fscanf(db, "%c", &tax);
fscanf(db, "%i", &Q);
}//end of while
return price;
} // end of Lookup_Item_Price()
char Lookup_Item_Taxability(FILE *db, int item){
while (in !=item){
fscanf(db, "%i", &in);
fscanf(db,"%lf\n" &price);
fscanf(db, "%c", &tax);
fscanf(db, "%i", &Q);
}//end of while
return tax;
} // end of Lookup_Item_Taxability()
double Compute_Tax(FILE *db, int item, int qty){
switch(tax, Q){
case 'O'
case 'T'
case 'N'
}//end of switchcase
} // end of Compute_Tax()
int Create_Receipt(FILE *db, int items[][2], int itemcnt){
} // end of Create_Receipt()
Thanks.