hi guys.. i'm doing this program.. haven't finished it yet..
i'm not getting any errors but the program is not running correctly.. I dunnu y,, i did everything i had to and it says 1 succeeded with no warnings !


here is my code..

#include <iostream>
#include <fstream>
#include <cstdlib>

using namespace std;
int main ()
{

	int num;
	
	do
	{
	cout<<endl
		<<"*****************************************"<<endl
		<<"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. Ticket sales"<<endl
		<<"4. Membership and frequent flier miles"<<endl
		<<"5. Ticket sales"<<endl
		<<"6. Special offers"<<endl
		<<"7. Frequently asked questions"<<endl
		<<"8. Contact us"<<endl
		<<"* Press 0 to exit"<<endl
		<<"*****************************************"<<endl<<endl;
	
	cin>>num;

	cout<<endl;
	num++
	
	}while(num!=0);

	

	switch (num)
	{

	case (0):

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


	case (1):

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

	default:
		cout<<"Invalid number. Please choose again.";
	break;
	
	
	
	}


return 0;
}

what is the problem?

lol.. i'm the one asking what is the probrem.. run the program and c !!

You don't have a semicolon after num++. There is no reason that I should have to compile your code to find out what the compiler errors are... post the compilers output next time. Also, there is not need to post 10 line cout statements, you should post the simplest working example possible. The following code has the same problems, but is much shorter.

#include <iostream>
#include <fstream>
#include <cstdlib>

using namespace std;
int main ()
{
	int num;
	do
	{
		cout<< "something" <<endl;
		cin>>num;
		cout<<endl;
		num++
	
	}while(num!=0);

	switch (num)
	{

		case (0):
			cout << "End of program"<<endl;
		case (1):
			cout<<"something else"<<endl; 
			break;
		default:
			cout<<"Invalid number. Please choose again.";
			break;	
	}
	return 0;
}

You don't seem to be handling case 0 at all, if you want to end the program you could use

return 0;

or

exit(-1); //from stdlib

Dave

ok this is it.. i've removed the num++ coz without it case 0 is working :S

#include <iostream>


using namespace std;
int main ()
{

	int num;
	
	do
	{
	cout<<endl
		<<"*****************************************"<<endl
		<<"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. Ticket sales"<<endl
		<<"4. Membership and frequent flier miles"<<endl
		<<"5. Ticket sales"<<endl
		<<"6. Special offers"<<endl
		<<"7. Frequently asked questions"<<endl
		<<"8. Contact us"<<endl
		<<"* Press 0 to exit"<<endl
		<<"*****************************************"<<endl<<endl;
	
	cin>>num;


	cout<<endl;
	
	
	}while(num!=0);

	

	switch (num)
	{

	case (0):

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


	case (1):

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

	default:
		cout<<"Invalid number. Please choose again.";
	break;
	
	
	
	}



return 0;
}

and this is the compiler's message:

1>------ Build started: Project: WFF, Configuration: Debug Win32 ------
1>Compiling...
1>5ra S.cpp
1>Linking...
1>Embedding manifest...
1>Build log was saved at "file://c:\Users\fofa\Documents\Visual Studio 2005\Projects\WFF\Debug\BuildLog.htm"
1>WFF - 0 error(s), 0 warning(s)
========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========

so, does that solve your problem or (since you never said what the problem was) is there more?

I see a problem from how the program should be running (although desired results would be nice to know...) it's in your do-while loop
Here's Dave's wonderfully simplified code:

#include <iostream>
#include <fstream>
#include <cstdlib>

using namespace std;
int main ()
{
	int num;
	do
	{
		cout<< "something" <<endl;
		cin>>num;
		cout<<endl;
		num++
	
	}while(num!=0);

	switch (num)
	{

		case (0):
			cout << "End of program"<<endl;
		case (1):
			cout<<"something else"<<endl; 
			break;
		default:
			cout<<"Invalid number. Please choose again.";
			break;	
	}
	return 0;
}

you will notice that the only value of num that will ever get to the switch is 0. Simple fix, move the do-while to include the switch statement:

#include <iostream>
#include <fstream>
#include <cstdlib>

using namespace std;
int main ()
{
	int num;
	do
	{
		cout<< "something" <<endl;
		cin>>num;
		cout<<endl;	

	        switch (num)
	        {

		        case (0):
			        cout << "End of program"<<endl;
                                break;
		        case (1):
			        cout<<"something else"<<endl; 
			        break;
		        default:
			        cout<<"Invalid number. Please choose again.";
			        break;	
	        }
        }
        while(num != 0);

	return 0;
}

see if that's what you're looking to do.

The thing is that i dunu what the freakin' problem is!!
the compiler shows no error or warning.. and the pro is not runniny correctly,, how the hell wd i know as i'm a begginer !!

check my last post, looks like you overlooked it.....

Here are things to help us solve issues with people's programs:
- Sample input/output (none provided)
- Desired input/output (none provided)
- Compiler output (none provided)

There is no reason that I should have to compile your code to find out what the compiler errors are...

I agree, essentially it's good practice (in my opinion) to make it as convenient as possible to help you. Please post the actual and desired input/output.

THANKS dude.. it's working properly now

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.