I have a code in here that u will multiply the number of seat and the number of ticket.
i think i got the correct return value but it's still not working when i times it it always = 0
need help thx
cout<< "Reserved Number of Tickets: " << rsrve.seatnum;
rsrve.pos=getPos(rsrve.seat);
cout<< "\nSeating Area is: " << rsrve.seatchoice[20];
cout<<endl;
rsrve.bill=getBill(rsrve.seat);
cout<< "Your Total Bill is: " <<rsrve.bill*rsrve.seatnum;
cout << endl << endl;
display ('=', 20);
cout << "\nThank you for patronizing One World Ticket reservation system!" << endl;
cout << "Input Another Transaction (Y/N)?\n";
cin>> rsrve.ans;
}
if(seatchoice=='FS'||seatchoice=='fs')
cout<<"Your Position is Front Seats";
if(seatchoice=='LBS'||seatchoice=='lbs')
cout<<"Your Position is Lower Box Seats";
if(seatchoice=='UBS'||seatchoice=='ubs')
cout<<"Your Position is Upper Box Seats";
if(seatchoice=='GPS'||seatchoice=='gps')
cout<<"Your Position is General Patronage Seats";
It's interesting that this compiles for you. Apostrophes are used for single characters, not strings.
And this is not how you compare C strings. (Do you even know what the , does in your case?)
And because you're a C++ programmer you should use C++ strings (std::string) instead of C strings.
I just put this in a compiler and the error list is massive. You need to sort out all the erros (They are fairly self explanatory) and all the warnings. Make sure you're compiling with pedantic errors on.
Create a program that will reserve a tickets for a concert of an International Artist. The program must correspond with the following requirements:
o It have the following seating areas with their respective prices such as: Front seats – 15,000.00, lower box seats - 10,000.00, Upper box seats – 5,000.00, General Patronage seats – 1,500.00.
o It must produce an accurate computation of the bills and shows the reserved seat numbers.
Sample Output:
Welcome to One World Ticket
Reservation System
How many ticket(s) would you like to reserve? : 2
Select Seating Area (FS – Front Seats, LBS – Lower Box Seats, UBS, Upper Box Seats, GPS – General Patronage Seats) : FS
= = = = = = = = = = = = = = =
Reserved number of tickets : 2
Seating Area is Front Seats
Your total bill is Php 30,000.00
Thank you for patronizing One World Ticket reservation system!
Input Another Transaction (Y/N)? Y
cout<< "Reserved Number of Tickets: " << rsrve.seatnum;
rsrve.pos=getPos(rsrve.seat);
cout<< "\nSeating Area is: " << rsrve.seatchoice[20];
cout<<endl;
rsrve.bill=getBill(rsrve.seat);
cout<< "Your Total Bill is: " <<rsrve.bill*rsrve.seatnum;
cout << endl << endl;
display ('=', 20);
cout << "\nThank you for patronizing One World Ticket reservation system!" << endl;
cout << "Input Another Transaction (Y/N)?\n";
cin>> rsrve.ans;
}
if(seatchoice=='FS'||seatchoice=='fs')
cout<<"Your Position is Front Seats";
if(seatchoice=='LBS'||seatchoice=='lbs')
cout<<"Your Position is Lower Box Seats";
if(seatchoice=='UBS'||seatchoice=='ubs')
cout<<"Your Position is Upper Box Seats";
if(seatchoice=='GPS'||seatchoice=='gps')
cout<<"Your Position is General Patronage Seats";
1) Please use code tags when posting code to make it readable. The more easy it is to read, the more easy it is for us to help you.
2) "not working" is spectacularly unhelpful. What do you mean? Is it failing to compile? Failing to run? Running but producing unexpected results? What errors/unexpected behaviour are you seeing?
Surely you can understand that withholding information from us makes it harder for us to help you?
cout<< "Reserved Number of Tickets: " << rsrve.seatnum;
cout<< "\nSeating Area is: " << rsrve.seatchoice, 20;
cout<< "\nYour Total Bill is: " << rsrve.seatnum*getBill(rsrve.seat);
cout << endl << endl;
display ('=', 20);
cout << "\nThank you for patronizing One World Ticket reservation system!" << endl;
cout << "Input Another Transaction (Y/N)?\n";
cin>> rsrve.ans;
}
char getpos(char seatchoice)
{
int p=0;
char choice;
if(seatchoice=='fs'||seatchoice=='FS')
char choice[]="your position is front seats";
if(seatchoice=='lbs'||seatchoice=='LBS')
char choice[]="your position is lower box seats";
if(seatchoice=='ubs'||seatchoice=='UBS')
char choice[]="your position is upper box seats";
if(seatchoice=='gps'||seatchoice=='GPS')
char choice[]="your position is general patronage seats";
still not working it say that
Error 1 error LNK2019: unresolved external symbol "char __cdecl getPos(char)" (?getPos@@YADD@Z) referenced in function _main C:\Users\Francis\Documents\Visual Studio 2012\Projects\Project4\Project4\Source1.obj Project4
//char getpos(char pos)
//{
// int p=0;
// char choice;
//if(pos=='fs'||pos=='fs')
// char choice[]="your position is front seats";
//if(pos=='lbs'||pos=='lbs')
// char choice[]="your position is lower box seats";
//if(pos=='ubs'||pos=='ubs')
// char choice[]="your position is upper box seats";
//if(pos=='gps'||pos=='gps')
// char choice[]="your position is general patronage seats";
//
//return p;
//}
You're not really reading the replies properly, you've been given all the answers already. I suspect you're trying to migrate to C++ from a very different language, and are still missing some key points. I hope you won't be offended by my approach - I've changed your program a bit (see below). First try building and running it it, then compare concepts with what you were trying to do. This may give you some more insight.
You may think the way I've written it is not very good, but I'm just trying to highlight some C++ concepts you're missing, without changing your code too much.
Also don't forget:
format
indent
and there's no way that code up there compiled.