Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

50 YEARS OLD MOM IS BACK ON HER LAST ASSIGNMENT

HEy Guys, I need help again. This is my last assignmnet and the instructor told us to change all of this to C++.

Actually I am taking C only and our instructor gave this last assignment by converting the last lab 3 to C++ or .cpp.

I even bought this small pamplet on how C++ study guide but I cannot understand it yet. I am going to get C++ next semester.

I have no idea on how to do this, so I need help/
Please.......

#include
#include
#include /*for toupper*/
#include /*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("=============================
");
printf(" %s
", TITLE);
printf("=============================

");
printf("1 Enter Customer Information
");
printf("2 Enter Rental Information
");
printf("3 Compute Charges
");
printf("4 Display Receipt
");
printf("5 Exit Program

");
printf(" Selection: ");
scanf("%d",&choice);
getchar();

if(choice==1)
{
/*intialise next customer*/
initialise(VideoTitle,Category,Late,price,DaysRent
ed);
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

", TITLE);
printf("Customer Name: ");
gets(Fullname);
printf(" Address: ");
gets(Address);
printf(" City/State/Zip: ");
gets(City);
printf("

");
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

", TITLE);
printf("Customer Name: %s
", Fullname);
printf("Coupon Presented: %s

", 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("

");

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("

");
}

}
double computecharges(double charge, float price[], int DaysRented[], char Category[],char CouponApplied[], double Tax)
{
int i;

i = 0;

while((Category[i] != ' ') && (Category[i] != ''))
{
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

", TITLE);
printf( "Customer Name : %s
", Fullname);
printf( " Address: %s
", Address);
printf( " City/State/Zip: %s

", City);
printf("Coupon Presented (Y/N): %s

", CouponApplied);


printf(" Days Coupon
");
printf("No. Video Title Category Rented Applied Late/Lost Charge
");
printf("=== ========================= ======== ====== ======== ========= =======
");

while((Category[i] != ' ') && (Category[i] != ''))
{
printf("%-1i. %-28s%-11c%-6d%-12s%-7s%7f
", i + 1, VideoTitle[i], Category[i], DaysRented[i],
CouponApplied, Late[i], price[i]);
i++;
}
Tax = 0.086 * charge;

printf("

Subtotal : %5.2lf"
"
Tax (8.6%%) : %5.2lf"
"
Total Due : %5.2lf", charge,Tax,Tax+charge);

printf("

Hit 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], "");
strcpy(Late[i], " ");
Category[i] = ' ';
price[i] = 0.0;
DaysRented[i] = 0;
}
Category[i] = '';
}


Comments

  • dudeapcdudeapc Member Posts: 12
    i'm not sure when i try to compile it i get these errors:
    92 C:Dev-Cppmisc sourcesUntitled2.cpp parse error before `{'
    C:Dev-Cppmisc sourcesUntitled2.cpp [Warning] In function `int main()':
    I am the evil face in your dreams.
    I am the one who fills you with despair.
    I am 666.

  • lokarettelokarette Member Posts: 3
    I do hope your OK and I think you need help. The program is working good and it does not say all what you are saying:
    Go find a psychiatrist Mr Dudeapc. You are compiling a different code not the code that I place.
    Mom

    i'm not sure when i try to compile it i get these errors:
    : 92 C:Dev-Cppmisc sourcesUntitled2.cpp parse error before `{'
    : C:Dev-Cppmisc sourcesUntitled2.cpp [Warning] In function `int main()':
    : I am the evil face in your dreams.
    : I am the one who fills you with despair.
    : I am 666.
    :
    :

  • dudeapcdudeapc Member Posts: 12
    [b][red]This message was edited by dudeapc at 2002-8-15 9:24:21[/red][/b][hr]
    I was compiling in c++ before but now when i compile in c i get:
    C:Dev-Cppmisc sourcesmovie rental2.c [Warning] In function `main'
    90 C:Dev-Cppmisc sourcesmovie rental2.c parse error before `void'

    edit: never mind that i got it working i only know that printf(); is replaced by cout << "Your Text here" << $somevariable << "More text here";
    and scanf(); is replaced by cin << "string type like %c or %s", $variable;
    but if you want a C++ tutorial here is the link for the free online version of Sams Teach yourself C++ in 21 Days if it asks for your eamil type it in ::: http://165.193.123.40/isapi/product_id~{83B8BE68-A805-4140-9F48-F2540866AC50}/element_id~{8225C863-B850-44F8-816E-BEB15F9E87A1}/st~C11E7D9E-5668-42A0-8EBD-2921F365F9B5/session_id~{9656782D-61C0-4DC6-93A3-126DBBB23AFF}/content/articlex.asp

    just copy and paster that and if u get a 404 then look in the url and remove any %20 that is the hexadecimanl? equivalent of the spacebar

    I am the evil face in your dreams.
    I am the one who fills you with despair.
    I am 666.



Sign In or Register to comment.