the 50 years old mom is back and need help again
HEy Guys, I need help again. This is my last assignmnet and the instructor told us to change all of this to C++.
I have no idea on how to do this, so I need help/
Please.......
Code:
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h> /*for toupper*/
#include <string.h> /*needed for strcpy()*/
#define MAX_NAME 30
#define TITLE "Mabuhay Video Store"
#define MAX_VIDEO 10
void getcustomer(char Fullname[],char Address[],char City[],
char CouponApplied[], char Y);
void getVideos(char Fullname[],char CouponApplied[],char VideoTitle[][MAX_NAME + 1],
char Category[], int DaysRented[]);
double computecharges(double charge, float price[], int DaysRented[], char Category[],char CouponApplied[], double Tax);
void displayreceipt(char Fullname[],char Address[],char City[],
char VideoTitle[][MAX_NAME + 1],char Category[],
int DaysRented[],char CouponApplied[],
char Late[][5],float price[], char Y, double Tax, double charge);
void initialise(char VideoTitle[][MAX_NAME + 1],char Category[],char Late[][5],
float price[],int DaysRented[]);
int main(void)
{
char Fullname[MAX_NAME + 1];
char Address[MAX_NAME + 1];
char City[MAX_NAME + 1];
char CouponApplied[4];
int choice;
char Y = 'N';
char VideoTitle[10][MAX_NAME + 1];
char Category[10];
int DaysRented[10];
float price[10];
char Late[10][5];
double charge = 0.0;
double Tax = 0.0;
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)
{
/*intialise next customer*/
initialise(VideoTitle,Category,Late,price,DaysRented);
getcustomer(Fullname,Address,City,CouponApplied, Y);
}
else if(choice==2)
{
getVideos(Fullname,CouponApplied, VideoTitle,Category, DaysRented);
}
else if(choice==3)
{
charge = computecharges(charge, price, DaysRented, Category, CouponApplied, Tax);
}
else if(choice==4)
{
displayreceipt(Fullname, Address, City, VideoTitle, Category,
DaysRented, CouponApplied, Late,price, Y, Tax,charge);
}
else
{
break;
}
}
while(choice!=5);
return EXIT_SUCCESS;
void getcustomer(char Fullname[], char Address[], char City[],
char CouponApplied[], 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("\n\n");
printf("Coupon Presented (Y/N): ");
scanf("%c", &Y);
getchar();
Y = toupper(Y);
if(Y = 'Y')
strcpy(CouponApplied, "YES");
else
strcpy(CouponApplied, "NO");
}
void getVideos(char Fullname[],char CouponApplied[],char VideoTitle[][MAX_NAME + 1],
char Category[], int DaysRented[])
{
int i, count;
system("cls");
printf("Store Name: %s\n\n", TITLE);
printf("Customer Name: %s\n", Fullname);
printf("Coupon Presented: %s\n\n", CouponApplied);
/*user has to rent 10 videos using for loop
to allow for any number of
videos between 1 and 10 inclusive*/
printf("How many videos > ");
scanf("%d",&count);
getchar();
printf("\n\n");
for (i = 0; i < count; i++)
{
printf("%i. VideoTitle: ", i+1);
gets(VideoTitle[i]);
printf(" Category(N,R,C,B): ");
scanf( "%c",&Category[i]);
getchar();
Category[i] = toupper(Category[i]);
printf(" DaysRented: ");
scanf("%d", &DaysRented[i]);
getchar();
printf("\n\n");
}
}
double computecharges(double charge, float price[], int DaysRented[], char Category[],char CouponApplied[], double Tax)
{
int i;
i = 0;
while((Category[i] != ' ') && (Category[i] != '\0'))
{
if (Category[i] == 'N')
price[i] = DaysRented[i] * 2.99f;
else if (Category[i] =='R')
{
price[i] = DaysRented[i] * 3.99f;
if (strcmp(CouponApplied, "Yes") == 0)
price[i] = price[i] - 1.0f;
}
else if (Category[i] == 'C')
{
price[i] = DaysRented[i] * 2.99f;
if (strcmp(CouponApplied, "Yes") == 0)
price[i] = price[i] - 1.0f;
}
else if (Category[i] == 'B')
price[i] = DaysRented[i] * 1.0f;
else if (DaysRented[i] == 0)
price[i] = 75.0f;
else if (DaysRented[i] == 90)
price[i] = 75.0f;
else if (DaysRented[i] == 90)
price[i] = 75.0f;
charge += price[i];
i++;
}
return charge;
}
void displayreceipt(char Fullname[],char Address[],char City[],
char VideoTitle[][MAX_NAME + 1],char Category[],int DaysRented[],
char CouponApplied[], char Late[][5], float price[], char Y, double Tax, double charge)
{
int i = 0;
system("cls");
printf( "Store Name : %s\n\n", TITLE);
printf( "Customer Name : %s\n", Fullname);
printf( " Address: %s\n", Address);
printf( " City/State/Zip: %s\n\n", City);
printf("Coupon Presented (Y/N): %s\n\n", CouponApplied);
printf(" Days Coupon \n");
printf("No. Video Title Category Rented Applied Late/Lost Charge\n");
printf("=== ========================= ======== ====== ======== ========= =======\n");
while((Category[i] != ' ') && (Category[i] != '\0'))
{
printf("%-1i. %-28s%-11c%-6d%-12s%-7s%7f\n", i + 1, VideoTitle[i], Category[i], DaysRented[i],
CouponApplied, Late[i], price[i]);
i++;
}
Tax = 0.086 * charge;
printf("\n\n Subtotal : %5.2lf"
"\n Tax (8.6%%) : %5.2lf"
"\n Total Due : %5.2lf", charge,Tax,Tax+charge);
printf("\n\nHit any key to continue");
getchar();
}
void initialise(char VideoTitle[][MAX_NAME + 1],char Category[],char Late[][5],
float price[],int DaysRented[])
{
int i;
for(i = 0; i < MAX_VIDEO; i++)
{
strcpy(VideoTitle[i], "\0");
strcpy(Late[i], " ");
Category[i] = ' ';
price[i] = 0.0;
DaysRented[i] = 0;
}
Category[i] = '\0';
}
Code tags added by kermi3