This is my CS101 final project
i have to make a whole programe by myself.
its a programe for a flight agency
its still incomplete, i knwo it still needs alot of work
but i keep getting 4 errors when compailing
i want to solve them so i can move on with the next steps.
PLEASE HELP ME!!!

#include <iostream>
#include<cstdlib>
double DOLLAR_TO_YEN (double dollar_Z);
//This function converts values from Dollar to Yen.

using namespace std;
int main ()
{


	int num,travel_YN,num_destination,stat_pk,asia_pk,dom_destination;
	
	
	do
	{
		cout << "\t\t\t =================    "<<endl;
		cout << "\t\t\t     ||   || || ||    "<<endl;
		cout << "\t\t\t     ||   || || ||    "<<endl;
		cout << "\t\t\t     ||      || ||    "<<endl;
		cout << "\t\t\t \\   ||         ||   "<<endl;
		cout << "\t\t\t  \\  ||              "<<endl;
		cout << "\t\t\t   \\ ||              "<<endl;
		cout << "\t\t\t    \\||  J-Otaku-Air "<<endl;
		cout <<endl;
		cout <<endl;

	cout<<"Welcome to J-Otaku-Air travel agency."<<endl
		<<"Please choose a number from the following menu, then press enter to "
		<<"move to the desired page."<<endl<<endl
		<<"1. About J-Otaku-Air"<<endl
		<<"2. Reservations"<<endl
		<<"3. Currency Converter"<<endl
		<<"4. Budget Travels & Special Offers"<<endl
		<<"5. Frequently asked questions"<<endl
		<<"6. Contact us"<<endl
		<<"* Press 0 to exit"<<endl<<endl;
	
	

	cin>>num;
	cout<<endl;
	


	switch (num)
	{

	case 0:

	cout << "End of program"<<endl;


	case 1:

	cout<<"1. About J-Otaku-Air"<<endl
		<<endl
		<<"J-Otaku-Air was founded on July 1990. Founded by two individuals in an"<<endl
		<<"extraordinary partnership."<<endl
		<<"Wareef Al-Omair and Fadia Banafe built this company with the goal of helping"<<endl
		<<"accommodate the curious nature of people and their need for exploration. "<<endl
		<<"Throuh out the years, J-Otaku-Air has been thriving to expand its services and"<<endl
		<<"offer the best for their clients. And along their journey their hard work has"<<endl
		<<"been rewarded by many establishments."<<endl
		<<"In hopes of seeing you in one of our flights."<<endl<<endl
		<<"Sincerely,"
		<<endl<<endl
		<<"   J-Otaku-Air"<<endl; 
	
	
	break;
	
	

	case 2:
	int Passenger_name;

	cout << "2.Reservations:"<<endl
		<<endl
		 << "Hello and welcome to the reservation area."<<endl
		 << "Here you can choose your desired travel location and book a flight directly."<<endl
		 <<endl;
	cout << "Please enter your full name to begin."<<endl;
	cin  >> Passenger_name;

           do {     	
			   cin.get(Passenger_name);
			   cout << Passenger_name;        
		   } while (Passenger_name != '\n');


		cout << "Do you intend on traveling internationally? (Y/N)\a"<<endl;
	cin  >>travel_YN;
	
	if ((travel_YN=='N')|| (travel_YN=='n'))
	{
	cout << "You choose to travel domestically,"<<endl
		 << "Please choose a destination from the following list:"<<endl;
	cout << "1.Hiroshima"<<endl;
	cout << "2.Nagasaki"<<endl;
	cout << "3.Osaka"<<endl;
	cout << "4.Yokohama"<<endl;
	
	cin  >> dom_destination;

	switch (dom_destination)
	{

		do	{
	case 1:
		int numb_seats,Hiroshima_tkt;
		char convert_YN,pick_YN;

		cout << "You chose Hiroshima, is that correct? (Y/N)\a"<<endl;
		cin  >> pick_YN;

		cout << "The price of each seat from Tokyo to Hiroshima costs 200 Dollars"<<endl;
		cout << "Would you like to convert that amount into Yen?(Y/N)\a"<<endl;
		cin  >> convert_YN;
		if ((convert_YN=='Y') || (convert_YN=='y'))
		{
		
				//convertion function call

		double dl_2_yn,crvrtd_dl;
		cout << "Please enter the value in Dollars that you want to convert to Yen"<<endl;
		cin  >> dl_2_yn;

		crvrtd_dl = DOLLAR_TO_YEN (dl_2_yn);

		cout << dl_2_yn << "$ = " <<crvrtd_dl<< " Yen "<<endl;
		}
		else 
		{
		double yen_tkt_cost,tkt_cost;

		cout << "How many seats would you like to reserve?"<<endl;
		cin  >> numb_seats;

		cout << "You have booked "<<numb_seats<< " seats."<<endl;
	
		tkt_cost=200;
		cout << "The total cost of your ticket(s) will be:    "<<tkt_cost<<"$"<<endl;
		yen_tkt_cost=tkt_cost*95.1384264;
		cout << "which is "<<yen_tkt_cost<<endl;

		cout << "Dear, "<<Passenger_name<<endl;
		cout << "You have booked a flight to Hiroshima."<<endl;
		cout << "Please visit your nearest travel agency to conferm your reservation."<<endl;
		cout << "Also, keep in mind that this ticket is only valade"<<endl;
		cout << "for 3 monthes from the time of purchase."<<endl;
		break;
		}

		
	case 2:



		cout << "You chose Nagasaki, is that correct? (Y/N)\a"<<endl;
		cin  >> pick_YN;

		cout << "The price of each seat from Tokyo to Nagasaki costs 200 Dollars"<<endl;
		cout << "Would you like to convert that amount into Yen?(Y/N)\a"<<endl;
		cin  >> convert_YN;
		if ((convert_YN=='Y') || (convert_YN=='y'))
		{
		
				//convertion function call

		double dl_2_yn,crvrtd_dl;
		cout << "Please enter the value in Dollars that you want to convert to Yen"<<endl;
		cin  >> dl_2_yn;
	
		crvrtd_dl = DOLLAR_TO_YEN (dl_2_yn);

		cout << dl_2_yn << "$ = " <<crvrtd_dl<< " Yen "<<endl;
		}
		else 
		{
		double yen_tkt_cost,tkt_cost;

		cout << "How many seats would you like to reserve?"<<endl;
		cin  >> numb_seats;

		cout << "You have booked "<<numb_seats<< " seats."<<endl;
	
		tkt_cost=200;
		cout << "The total cost of your ticket(s) will be:    "<<tkt_cost<<"$"<<endl;
		yen_tkt_cost=tkt_cost*95.1384264;
		cout << "which is "<<yen_tkt_cost<<endl;

		cout << "Dear, "<<Passenger_name<<endl;
		cout << "You have booked a flight to Nagasaki."<<endl;
		cout << "Please visit your nearest travel agency to conferm your reservation."<<endl;
		cout << "Also, keep in mind that this ticket is only valade"<<endl;
		cout << "for 3 monthes from the time of purchase."<<endl;
		}
break;


	case 3: 
		{
		int numb_seats,Osaka_tkt;
		char convert_YN,pick_YN;

		cout << "You chose Osaka, is that correct? (Y/N)\a"<<endl;
		cin  >> pick_YN;

		cout << "The price of each seat from Tokyo to Osaka costs 200 Dollars"<<endl;
		cout << "Would you like to convert that amount into Yen?(Y/N)\a"<<endl;
		cin  >> convert_YN;
		if ((convert_YN=='Y') || (convert_YN=='y'))
		{
		
				//convertion function call

		double dl_2_yn,crvrtd_dl;
		cout << "Please enter the value in Dollars that you want to convert to Yen"<<endl;
		cin  >> dl_2_yn;
	
		crvrtd_dl = DOLLAR_TO_YEN (dl_2_yn);

		cout << dl_2_yn << "$ = " <<crvrtd_dl<< " Yen "<<endl;
		}
		else 
		{
		double yen_tkt_cost,tkt_cost;

		cout << "How many seats would you like to reserve?"<<endl;
		cin  >> numb_seats;

		cout << "You have booked "<<numb_seats<< " seats."<<endl;
	
		tkt_cost=200;
		cout << "The total cost of your ticket(s) will be:    "<<tkt_cost<<"$"<<endl;
		yen_tkt_cost=tkt_cost*95.1384264;
		cout << "which is "<<yen_tkt_cost<<endl;

		cout << "Dear, "<<Passenger_name<<endl;
		cout << "You have booked a flight to Osaka."<<endl;
		cout << "Please visit your nearest travel agency to conferm your reservation."<<endl;
		cout << "Also, keep in mind that this ticket is only valade"<<endl;
		cout << "for 3 monthes from the time of purchase."<<endl;
		
		break;
		
		}

	case 4:
		{
		cout << "You chose Yokohama, is that correct? (Y/N)\a"<<endl;
		cin  >> pick_YN;

		cout << "The price of each seat from Tokyo to Yokohama costs 200 Dollars"<<endl;
		cout << "Would you like to convert that amount into Yen?(Y/N)\a"<<endl;
		cin  >> convert_YN;
		if ((convert_YN=='Y') || (convert_YN=='y'))
		{
		
				//convertion function call

		double dl_2_yn,crvrtd_dl;
		cout << "Please enter the value in Dollars that you want to convert to Yen"<<endl;
		cin  >> dl_2_yn;
	
		crvrtd_dl = DOLLAR_TO_YEN (dl_2_yn);

		cout << dl_2_yn << "$ = " <<crvrtd_dl<< " Yen "<<endl;
		}
		else 
		{
		double yen_tkt_cost,tkt_cost;

		cout << "How many seats would you like to reserve?"<<endl;
		cin  >> numb_seats;

		cout << "You have booked "<<numb_seats<< " seats."<<endl;
	
		tkt_cost=200;
		cout << "The total cost of your ticket(s) will be:    "<<tkt_cost<<"$"<<endl;
		yen_tkt_cost=tkt_cost*95.1384264;
		cout << "which is "<<yen_tkt_cost<<endl;

		cout << "Dear, "<<Passenger_name<<endl;
		cout << "You have booked a flight to Yokohama."<<endl;
		cout << "Please visit your nearest travel agency to conferm your reservation."<<endl;
		cout << "Also, keep in mind that this ticket is only valade"<<endl;
		cout << "for 3 monthes from the time of purchase."<<endl;
		
		break;
		}
	       	} while  ((pick_YN =='Y') || (pick_YN == 'y'));

		break;
		}



		 cout << "Please choose a destination from the following list:"<<endl
			  <<endl;
			  do {
	   	 cout << "1. America"<<endl
		   	  << "2. Asia"<<endl
			  << "3. Australia"<<endl
			  << "4. Europe"<<endl
			  << "pree 0 to exit this menu."<<endl;
	   	 cin  >>num_destination;


		switch (num_destination)
		{
		case 1:			
		
			cout << "Please choose the state you would like to visit:"<<endl
				 << "1. California"<<endl
				 << "2. Florida"<<endl
				 << "3. New York"<<endl;
			cin  >> stat_pk;
			
			if (stat_pk==1)
			{
				
				
		cout << "You chose California,America. Is that correct? (Y/N)\a"<<endl;
		cin  >> pick_YN;
	
		cout << "Round trip from Tokyo to California,America 3500$ per ticket."<<endl; 
		cout << "Would you like to convert that amount into Yen?(Y/N)\a"<<endl;
		cin  >> convert_YN;
		if ((convert_YN=='Y') || (convert_YN=='y'))
		{
		
				//convertion function call

		double dl_2_yn,crvrtd_dl;
		cout << "Please enter the value in Dollars that you want to convert to Yen"<<endl;
		cin  >> dl_2_yn;
	
		crvrtd_dl = DOLLAR_TO_YEN (dl_2_yn);

		cout << dl_2_yn << "$ = " <<crvrtd_dl<< " Yen "<<endl;
		}
			}
		else 
		{
		double yen_tkt_cost,tkt_cost;

		cout << "How many seats would you like to reserve?"<<endl;
		cin  >> numb_seats;

		cout << "You have booked "<<numb_seats<< " seats."<<endl;
	
		tkt_cost=3500;
		cout << "The total cost of your ticket(s) will be:    "<<tkt_cost<<"$"<<endl;
		yen_tkt_cost=tkt_cost*95.1384264;
		cout << "which is "<<yen_tkt_cost<<endl;

		cout << "Dear, "<<Passenger_name<<endl;
		cout << "You have booked a flight to California,America."<<endl;
		cout << "Please visit your nearest travel agency to conferm your reservation."<<endl;
		cout << "Also, keep in mind that this ticket is only valade"<<endl;
		cout << "for 3 monthes from the time of purchase."<<endl;
		
			}
			 if (stat_pk==2)
			{

			 
					
			
		cout << "You chose Florida,America. Is that correct? (Y/N)\a"<<endl;
		cin  >> pick_YN;
	
		cout << "Round trip from Tokyo to Florida,America 2500$ per ticket."<<endl; 
		cout << "Would you like to convert that amount into Yen?(Y/N)\a"<<endl;
		cin  >> convert_YN;
		if ((convert_YN=='Y') || (convert_YN=='y'))
		{
		
				//convertion function call

		double dl_2_yn,crvrtd_dl;
		cout << "Please enter the value in Dollars that you want to convert to Yen"<<endl;
		cin  >> dl_2_yn;
	
		crvrtd_dl = DOLLAR_TO_YEN (dl_2_yn);

		cout << dl_2_yn << "$ = " <<crvrtd_dl<< " Yen "<<endl;
		}
		else 
		{
		double yen_tkt_cost,tkt_cost;

		cout << "How many seats would you like to reserve?"<<endl;
		cin  >> numb_seats;

		cout << "You have booked "<<numb_seats<< " seats."<<endl;
	
		tkt_cost=2500;
		cout << "The total cost of your ticket(s) will be:    "<<tkt_cost<<"$"<<endl;
		yen_tkt_cost=tkt_cost*95.1384264;
		cout << "which is "<<yen_tkt_cost<<endl;

		cout << "Dear, "<<Passenger_name<<endl;
		cout << "You have booked a flight to Florida,America."<<endl;
		cout << "Please visit your nearest travel agency to conferm your reservation."<<endl;
		cout << "Also, keep in mind that this ticket is only valade"<<endl;
		cout << "for 3 monthes from the time of purchase."<<endl;	
			 
			 }
			 if (stat_pk==3)
			{
			
		cout << "You chose New York,America. Is that correct? (Y/N)\a"<<endl;
		cin  >> pick_YN;
	
		cout << "Round trip from Tokyo to New York,America 2500$ per ticket."<<endl; 
		cout << "Would you like to convert that amount into Yen?(Y/N)\a"<<endl;
		cin  >> convert_YN;
		if ((convert_YN=='Y') || (convert_YN=='y'))
		{
		
				//convertion function call

		double dl_2_yn,crvrtd_dl;
		cout << "Please enter the value in Dollars that you want to convert to Yen"<<endl;
		cin  >> dl_2_yn;
	
		crvrtd_dl = DOLLAR_TO_YEN (dl_2_yn);

		cout << dl_2_yn << "$ = " <<crvrtd_dl<< " Yen "<<endl;
		}
		else 
		{
		double yen_tkt_cost,tkt_cost;

		cout << "How many seats would you like to reserve?"<<endl;
		cin  >> numb_seats;

		cout << "You have booked "<<numb_seats<< " seats."<<endl;
	
		tkt_cost=1500;
		cout << "The total cost of your ticket(s) will be:    "<<tkt_cost<<"$"<<endl;
		yen_tkt_cost=tkt_cost*95.1384264;
		cout << "which is "<<yen_tkt_cost<<endl;

		cout << "Dear, "<<Passenger_name<<endl;
		cout << "You have booked a flight to New York,America."<<endl;
		cout << "Please visit your nearest travel agency to conferm your reservation."<<endl;
		cout << "Also, keep in mind that this ticket is only valade"<<endl;
		cout << "for 3 monthes from the time of purchase."<<endl;
		

			}	
				
			break;
///////////// THIS PART IS INCOMPLETE!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
		case 2:

			cout << "Please choose your Required destanation in Asia:"<<endl
				 << "Beijing,China"<<endl
				 << "Singapore"<<endl
				 << "Manila,Philippines"<<endl;
			cin  >> asia_pk;


			if (asia_pk==1)
			{
				cout << "Round trip from Tokyo to Beijing,China 600$ per ticket."<<endl; 
				
			}
			else if (asia_pk==2)
			{
				cout << "Round trip from Tokyo to Singapore 500$ per ticket."<<endl;
			}
			else if (asia_pk==3)
			{
				cout << "Round trip from Tokyo to Manila,Philppines 450$ per ticket."<<endl;


			}


		break;

		}



















			  }while (num_destination!=0);


	
	break;


	




}while(num!=0);

return 0;
}


double DOLLAR_TO_YEN (double dollar_Z )
{

	double crvrtd_dl,dollar_Z;

		
	crvrtd_dl=dollar_Z*95.1384264;


return (crvrtd_dl);
}

Recommended Answers

All 9 Replies

There are many things wrong with your code.

But first, a question.
How many lines did you write before pressing "compile"?
If it was more than 10, then read this
It's quite simple, if you only write 10 lines, press compile and get a new compiler error message, you've got a damn good idea where to start looking.

Write 500 lines (what it looks like you tried to do), then you get 100's of error messages, and no clue how to fix them, save for posting the whole sorry mess on a forum for someone else to figure out.

We're not "code rescue rangers". Adopt a better approach to writing programs.

Now the problems.
1. Your main() is over 500 lines long, break it up into functions.
2. You've used a chaotic mix of spaces and tabs to indent your code. Your editor might make sense of it, but trust me, it's a mess when posted on a forum.
3. What you think is the closing brace of main at around line 521 matches the brace at about line 300. You're way off.

Using lots of functions would help, so that you don't end up with a deeply nested brace-fest inside main.

commented: Nice link. +11
commented: Good advice. +16

Lines 113 and 114 read:
cout << "You chose Hiroshima, is that correct? (Y/N)\a"<<endl;
cin >> pick_YN;

This is annoying the user. He just DID choose Hiroshima. Besides as far as I can figure out you do nothing with pick_YN. You might as well leave these 2 lines out(the same for other destinations)

heey dude..!! it's not my fault the first time i do a project !!
i said help me dude.. not make fun of my code.. I know it's not that perfect.. but this is the best i can do!! i didn't post my code here so that u'd say :

Write 500 lines (what it looks like you tried to do), then you get 100's of error messages, and no clue how to fix them, save for posting the whole sorry mess on a forum for someone else to figure out.

That hurts dude!! u turned me down !!

i know it is annoying !! all the yes no!!
but my profesor asked us to control the program this way !

if u have other ideas of controlling the program.. please notify me !

thnks for the advice.

He's not making fun of your code, he's critiquing it and offering advice on how to design a program. Blunt, yes, but programming is a blunt field. You need to develop a thick skin, take a deep breath, and don't worry about the TONE, but take the ADVICE, which is good advice you should follow.

http://catb.org/esr/faqs/smart-questions.html#keepcool

See the link he linked as well. It gives good advice on how to approach programming. You need to do it a few lines at a time. Just about everyone starts out the way you have, writing way too much in a single block of code or a function, so don't feel too bad about it, but it is a habit that needs to be broken. Also note the tabs versus spaces point he made. Good IDEs have a way to change tabs to spaces with a single click. Mixing tabs and spaces makes it impossible to read when posting on a forum.

commented: Good team back up buddy !!! +2

I was going to say something here, but VernonDozier already said it very well.
Follow the wise advice of Salem : Compile as soon as you can!

First off, I agree that you should compile often.
Second: The main point, there are FAR too many fixed numbers.
e.g. "Round trip from Tokyo to Florida,America 2500$ per" That is horrific. Put

const double TokyoFloridaCost(2500);
const double YenDollarExchangeRate(14.3);

at the top of the code and use the variable. You can then use in all the places that you require it and if you need to change it then it is easy.

Also BE VERY careful about money in C++, I use a dedicated class, because you can charge someone 14.342 dollars (except in some very special cases) but often you need to keep track of the tiny bits e.g. 7% sales tax on 1.50dollar item is charged as 11cents but at the end of the day you give the tax man his fraction on total says to the nearest penny.

Additionally, I think your conversion are strange. I read your logic,
you tell the person the cost in dollars, ask if they want to convert it to yen and THEN ask them the number of dollars to convert?? JUST tell them how many yen 200 dollars is. Have a separte function to do just convertions if the customer can convert his currency.

Finally, why would a person.

heey dude..!! it's not my fault the first time i do a project !!
i said help me dude.. not make fun of my code.. I know it's not that perfect.. but this is the best i can do!! i didn't post my code here so that u'd say :

That hurts dude!! u turned me down !!

If you cannot compile the code written by you and you are supposed to submit your final year project assignment in a few days it shows you have not put even enough effort in classes,etc .

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.