|
Newbie
Join Date: Nov 2005
Posts: 1
Rep Power: 0 
|
HELP please!!!
I've been trying to get the errors of my program corrected for one week, but everytime I correct something I screw up something else. Could anyone help me clear the errors?
#include <stdio.h>
#include <string.h>
int order, paymet, ordnum=1, wrngpay;
int sweater[30], t_shirt[30], shrt[30], slack[30];
float swtot, tshtot, shrtot, slatot;
float total[30];
int validate_id(void);
int i, cost_id[30];
float calculate_order(int, int[], int[], int[], int[]);
char pay_method;
void print_report(int, int[], int[], int[], int[], int[], float[], char[]);
main() {
printf( " \n Welcome to C Fashion! \n " );
for(i =0;i<30; ++i)
do{
validate_id();
for(; validate_id() != -1; )
printf("\n Welcome, Costumer # %d \n", cost_id);
printf("\n\n\tProduct\t\tCost per Box\n");
printf("\n\t Sweaters \t$150\n");
printf("\n\t T-Shirts \t$100\n");
printf("\n\t Shorts \t$120\n");
printf("\n\t Slacks \t$200\n");
printf( " \n Welcome, Costumer # %d \n" , cost_id );
printf( "\n Please enter the number of sweaters you would like to order: " ) ;
scanf( "%d", &sweater[i] );
printf( " You have ordered %d sweaters. \n" , sweater);
printf( "\n Please enter the number of t-shirts you would like to order: " );
scanf( "%d", &t_shirt[i] );
printf( " You have ordered %d t-shirts. \n" , t_shirt );
printf( "\n Please enter the number of shorts you would like to order: " ) ;
scanf( "%d", &shrt[i] );
printf( " You have ordered %d shorts. \n" , shrt );
printf( "\n Please enter the number of slacks you would like to order: " ) ;
scanf( "%d", &slack[i] );
printf( " You have ordered %d slacks. \n \n" , slack );
if ( sweater || t_shirt || shrt || slack ) {
order = 1;
}
else order = 0;
if (order)
{
do {
printf("\n Select one of the following methods of payment\n");
printf("\n1\tCheck or money order\n2\tBank Transfer\n3\tCredit Card");
printf("\nEnter your selection: ");
scanf("%d", &paymet);
switch (paymet) {
case 1:
wrngpay = 0;
pay_method[i]="Check or money order";
break;
case 2:
wrngpay = 0;
pay_method[i]="Bank Transfer";
break;
case 3:
wrngpay = 0;
pay_method[i]="Credit Card";
break;
default:
wrngpay = 1;
printf("\n This is not a valid option");
}
} while (wrngpay);
printf("\nCustomer: #%d\n\n", cost_id);
swtot = sweater * 150 ;
tshtot = t_shirt * 100 ;
shrtot = shrt * 120 ;
slatot = slack * 200 ;
printf("%20s%10s%10s\n", "Product", "Boxes", "Cost");
if (sweater) printf("%20s%10d%10.2f\n", "Sweaters", sweater, swtot);
if (t_shirt) printf("%20s%10d%10.2f\n", "T-shirts", t_shirt, tshtot);
if (shrt) printf("%20s%10d%10.2f\n", "Shorts", shrt, shrtot);
if (slack) printf("%20s%10d%10.2f\n", "Slacks", slack, slatot);
printf("\n The for total for your order is: $ %.2f\n", calculate_order(i, sweater, t_shirt, shrt, slack);
printf("\n\n \t\tMethod of Payment: %s\n", pay_method[i] );
printf("\n\n \t\tEnd of order #%d \n\n", ordnum);
ordnum++ ;
}
else printf( "\n\n \t No items ordered!!! \n\n" );
printf("\n\n\t\t Thank you for using C Fashion!!!");
} while(i<30);
print_report(i, cost_id, sweater, t_shirt, shrt, slack, total, pay_method);
return 0;
}
/*-------------------------------------------------------------------------------------------------------*/
/* Function 1 */
int validate_id()
{
do{
printf("\n Please enter your costumer identification number or \"-1\" to exit. \n");
scanf("%d", cost_id);
if (cost_id >= 1 && cost_id <= 100) {
printf("You entered %d\n", cost_id);
return (cost_id);
}
else if (cost_id == -1)
return (-1);
else {printf("Invalid costumer identification number");}
} while (cost_id > -1 && cost_id > 100 );
}
/* Function 2 */
float calculate_order(int 30, int a[], int b[], int c[], int d[])
{
total[i]={0};
total[i] = total[i] + (150 * a[i]) + (100 * b[i]) + (120 * c[i]) + (200 * d[i]) ;
return total[i];
}
/* Function 3 */
void print_report(int i, int cost_id[], int sweater[], int t_shirt[], int shrt[], int slack[], float total[], char pay_method[])
{
printf("%20s%20s%20s%20s%20s%20s%20s\n", "customer id", "sweaters", "t-shirts", "shorts", "slacks", "total($)", "form of payment");
for(i=0; i < 30; i++)
printf("%20d%20d%20d%20d%20d%20.2f%20s\n", cost_id[i], sweater[i], t_shirt[i], shrt[i], slack[i], total[i], pay_method[i]);
}
/* End of Program */
All help is appreciated.
|