The 50 years old is back for help
Hello guys, This is the 50 years old MOm who go back to school and get C .Well,still have problem with my assignment. I got an error message when I select number 4 to display my receipt The program will shut down and so I cannot do anything to place all this:
This is what I need to do here:
Should display all customer / rental input and computed information. The output should be nicely formatted and include a tabular summary of the costs. Any input codes should be displayed as the "string" value they represent (e.g. category code of N shuld display New and Y for coupon should display Yes). The output might look like the following:
Days Coupon
No. Video Title Category Rented Applied Late/Lost Charge
=== ============================== ========
1. ======== New 0 No Lost 75.00
2. ====== Recent 10 Yes 14.96
3.======== Budget 91 No Late 19.00
Subtotal: $108.96
Tax (8.6%): $9.37
Total Due: $118.33
here is my program which give me an error when I select 4 so I cannot do anything. I tried to compute it before but still won't compile:
//header
#include <stdio.h>
#include <stdlib.h>
#define MAX_NAME 30
#define TITLE "Mabuhay Video Store"
#define MAX_VIDEO 10
void getcustomer(char Fullname[MAX_NAME + 1],char Address[MAX_NAME + 1],char City[MAX_NAME + 1],char Y);
void getVideos(char Fullname[MAX_NAME + 1],char Y,char VideoTitle[MAX_NAME + 1],char Category, int DaysRented);
void computecharges(double price, int DaysRented, char Category, char Y);
void displayreceipt(char Fullname[MAX_NAME + 1],char Address[MAX_NAME + 1],char City[MAX_NAME + 1],char Y, char VideoTitle[MAX_NAME + 1],char Category,int DaysRented,char CouponApplied[MAX_NAME + 1], char Late[MAX_NAME + 1], float Charge);
int main(void)
{
int choice;
char Fullname[MAX_NAME + 1];
char Address[MAX_NAME + 1];
char City[MAX_NAME + 1];
char Y = 'N';
char VideoTitle[MAX_NAME + 1];
char Category = 'R';
int DaysRented = 0;
double price = 0.0;
char No ='N';
char CouponApplied[MAX_NAME + 1];
char Late[MAX_NAME + 1];
float Charge = 0.0f;
do
{
system ("cls");
printf("=============================\n");
printf(" %s\n", TITLE);
printf("=============================\n\n");
printf("1 Enter Customer Information\n");
printf("2 Enter Rental Information\n");
printf("3 Compute Charges\n");
printf("4 Display Receipt\n");
printf("5 Exit Program\n\n");
printf(" Selection: ");
scanf("%d",&choice);
getchar();
if(choice==1)
{
getcustomer(Fullname,Address,City,Y);
}
else if(choice==2)
{
getVideos(Fullname,Y, VideoTitle,Category, DaysRented);
}
else if(choice==3)
{
computecharges(price, DaysRented, Category, Y);
}
else if(choice==4)
{
displayreceipt(Fullname, Address, City, Y, VideoTitle, Category, DaysRented, CouponApplied, Late, Charge);
}
else
{
break;
}
}while(choice!=5);
return EXIT_SUCCESS;
}
//header
void getcustomer(char Fullname[MAX_NAME + 1],char Address[MAX_NAME + 1],char City[MAX_NAME + 1],char Y)
{
system("cls");
printf("Store Name: %s\n\n", TITLE);
printf("Customer Name: ");
gets(Fullname);
printf(" Address: ");
gets(Address);
printf(" City/State/Zip: ");
gets(City);
printf("Coupon Presented (Y/N): ");
scanf("%c", &Y);
getchar();
}
//header
void getVideos(char Fullname[MAX_NAME + 1],char Y,char VideoTitle[MAX_NAME + 1],char Category, int DaysRented)
{
int i;
system("cls");
printf("Store Name: %s\n\n", TITLE);
printf("Customer Name: %s\n", Fullname);
printf("Coupon Presented: %c\n\n", Y);
for (i = 0; i < MAX_VIDEO; i++)
{
printf("%i. VideoTitle: ", i + 1);
gets(VideoTitle);
printf("Category(N,R,C,B): ");
scanf("%c",&Category);
printf("DaysRented: ");
scanf("%d", &DaysRented);
getchar();
}
}
//header
void computecharges(double price, int DaysRented, char Category,char Y)
{
if (Category == 'N')
price = DaysRented * 2.99;
else if (Category =='R')
{
price = DaysRented * 3.99;
if (Y == 'Y')
price = price - 1;
}
else if (Category == 'C')
{
price = DaysRented * 2.99;
if (Y == 'Y')
price = price - 1;
}
else if (Category == 'B')
price = DaysRented * 1.00;
else if (DaysRented == 0)
price = 75;
else if (DaysRented == 90)
price = 75;
price = price + price * 0.086;
}
//header
void displayreceipt(char Fullname[MAX_NAME + 1],char Address[MAX_NAME + 1],char City[MAX_NAME + 1],char Y, char VideoTitle[MAX_NAME + 1],char Category,int DaysRented,char CouponApplied[MAX_NAME + 1], char Late[MAX_NAME + 1], float Charge)
{
int i;
system("cls");
printf("Store Name: %s\n\n", TITLE);
printf("Customer Name: %s", Fullname);
printf(" Address: %s", Address);
printf(" City/State/Zip: %s", City);
printf("Coupon Presented (Y/N): %c", Y);
printf(" Days Coupon \n");
printf("No. Video Title Category Rented Applied Late/Lost Charge\n");
printf("=== =================== ======== ====== ======= ========= ======\n");
for (i = 0; i < MAX_VIDEO; i++)
{
printf("%i. %s %s %d %s %s %f\n", i + 1, VideoTitle, Category, DaysRented, Y, Late, Charge);
}
}
Please help as this is due tomorrow: Thank you again for all your help guys.
Thanks unregistered 22723
The 50 years old mom wants to thanks all who help me with my assignments and especially to this unregistered person who give his time to go all the way to make this code works.
Thanks
Mom from Seattle WA;)