not executing my if else loop

this the supposed output for this program that i'm working on


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


And here is my code.....

#include<iostream>
using namespace std;

int main()
{
int ticket, TotalPrice;
char seats, ans;

do
{
system("cls");

cout<< " Welcome to One World Ticket\n";
cout<< " Reservation System\n\n\n\n";
cout<< "How many ticket(s) would you like to reserve?: ";
cin>> ticket;
cout<< "Select seating area\n\n(Fs-Front Seats\n LBS-Lower Box Seats\n UBS-Upper Box Seats\n GPS-Gen. Patronage Seats): ";
cin>> seats;


if ((seats=='FS')||(seats=='fs')){
cout<<"\n\n===============================\n\n";
cout<<"Reserved number of ticket(s): "<<ticket;
cout<<"\nSeating area is: Front Seat";
cout<<"\nYour total bill is: "<<TotalPrice;
TotalPrice=15000*ticket;
cout<<"\n\nThank you for patronizing One World Ticket reservation system!\n";}

else if ((seats=='LBS')||(seats=='lbs')){
cout<<"\n\n===============================\n\n";
cout<<"Reserved number of ticket(s): "<<ticket;
cout<<"\nSeating area is: Lower Box Seat";
cout<<"\nYour total bill is: "<<TotalPrice;
cout<<"\n\nThank you for patronizing One World Ticket reservation system!\n";
TotalPrice=10000*ticket;}

else if ((seats=='UBS')||(seats=='ubs')){
cout<<"\n\n===============================\n\n";
cout<<"Reserved number of ticket(s): "<<ticket;
cout<<"\nSeating area is: Upper Box Seat";
cout<<"\nYour total bill is: "<<TotalPrice;
cout<<"\n\nThank you for patronizing One World Ticket reservation system!\n";
TotalPrice=5000*ticket;}

else if ((seats=='GPS')||(seats=='gps')){
cout<<"\n\n===============================\n\n";
cout<<"Reserved number of ticket(s): "<<ticket;
cout<<"\nSeating area is: General Patronage Seat";
cout<<"\nYour total bill is: "<<TotalPrice;
cout<<"\n\nThank you for patronizing One World Ticket reservation system!\n";
TotalPrice=1500*ticket;}

else{
cout<<"Invalid input.";
}

/*cout<<"\n\n===============================\n\n";
cout<<"Reserved number of ticket(s): "<<ticket;
cout<<"\nSeating Area is "<<seats;
cout<<"\nYour Total Bill is "<<TotalPrice;
cout<<"\n\nThank you for patronizing One World Ticket reservation system!\n";*/
cout<<"Do you want to try again?: type [Y] if yes, [N] if no: ";
cin>>ans;*/

}while(ans=='y'||ans=='Y');

system("pause>0");
}


my biggest headache is the program goes straight to the last "else" giving me "wrong input" message regardless of what i input. many thanks in advance!
Last edited on
Include header <string>, declare seats as
std::string seats;

and compare it with string literals as for example

if ( seats == "FS" || seats= == "fs" ) {
vlad from moscow
aaarrgghh!! that's a real big help. i have one more problem though

if ((seats=='FS')||(seats=='fs')){
cout<<"\n\n===============================\n\n";
cout<<"Reserved number of ticket(s): "<<ticket;
cout<<"\nSeating area is: Front Seat";
cout<<"\nYour total bill is: "<<TotalPrice;
TotalPrice=15000*ticket;
cout<<"\n\nThank you for patronizing One World Ticket reservation system!\n";}

it says my variable "TotalPrice" is being used without being initialized
maybe that's why it's not doing any computation at all.
how do you initialize this one?
again thank you for taking the time to answer.
You output TotalPrice but you did not assign it a value.

cout<<"\nYour total bill is: "<<TotalPrice;
Last edited on
Great!!
that last prob made me feel a bit stupid. :/
Nonetheless i'm happy i resorted to this forum for an answer, it's really worth the while everything is working perfectly now i just have some finishing touches to do. MANY MANY THANKS!! for helping out newbies like me. :)
Topic archived. No new replies allowed.