Hey, I got bored so decided to make this pointless program but am a bit confuzzled..

#include <iostream>

using namespace std;

int main()
{
    int decision;
    
    do
    {
        system("cls");
        
        cout << "Welcome to my pointless menu!" << endl;
        cout << "1 : Do Nothing." << endl << "2 : View Authors Details." << endl;
        cout << "3 : Quit" << endl << endl;
    
        cout << "Choose Your Decision : ";
        cin >> decision;
    }
    
    while( decision == 1 || decision < 1 || decision > 3 );
    
    switch( decision )
    {
            case 2:
                 system("cls");
                 
                 cout << "NAME : CRAIG AYRE" << endl;
                 cout << "SEX  : MALE" << endl;
                 cout << "AGE  : 14" << endl << endl;
                 
                 cout << "1 : Do Nothing." << endl << "2 : Return To Main Menu";
                 cout << endl << "3 : Quit";
                 
                 cout << "Choose Your Decision : ";
                 cin >> decision;
                 
                 cin.get();
                 
                 break;
                 
            case 3:
                 { }
                 
                 break;
    }
    
     do
    {
        system("cls");
        
        cout << "Welcome to my pointless menu!" << endl;
        cout << "1 : Do Nothing." << endl << "2 : View Authors Details." << endl;
        cout << "3 : Quit" << endl << endl;
    
        cout << "Choose Your Decision : ";
        cin >> decision;
    }
    
    while( decision == 2 );
    
    cin.get();
    
    return 0;
}

I've got the basic idea just I just thought, If I kept doing it i would have unlimited do loops, because the user could go view authors details go main menu.. go authors details.. etc etc.. please help :D

Recommended Answers

All 9 Replies

Why dont you put one do while loop that will stop if the user decides to exit the program. In this loop, you can use the switch statements to move through the choices.

Put the switch case inside do while

Because of lack of what to do too :)..I decided to modify the code you posted. Dont know if this is what you had in mind but it works according to your requirements

#include <iostream>

using namespace std;

int main()
{
    int decision;
    cout << "Welcome to my pointless menu!" << endl;
    cout << "1 : Do Nothing." << endl << "2 : View Authors Details." << endl;
	cout << "3 : Quit" << endl << endl;
    cout << "Choose Your Decision : ";
    
	cin >> decision;
	cout<<endl;


    do
    {
        system("cls");
       

		switch( decision )
		{
			case 1:
				system("cls");

				cout << "1 : Do Nothing." << endl << "2 : Return To Main Menu";
                 cout << endl << "3 : Quit"<<endl;
                 cout << "Choose Your Decision : ";
                 cin >> decision;
                 
                 cin.get();
			break;
			
			case 2:
                 system("cls");
                 
                 cout << "NAME : CRAIG AYRE" << endl;
                 cout << "SEX  : MALE" << endl;
                 cout << "AGE  : 14" << endl << endl;
                 
                 cout << "1 : Do Nothing." << endl << "2 : Return To Main Menu";
                 cout << endl << "3 : Quit"<<endl;
                 
                 cout << "Choose Your Decision : ";
                 cin >> decision;
                 
                 cin.get();     
			break;
                 
            case 3:
                 exit(-1);
			break;

			default: cout<<"Wrong selection!"<<endl;
		}
    }while(decision!='3');
    
    return 0;
}

[EDIT] This code was not indented properly by the OP and even if i have nothing to do at the moment, Iam too lazy to format it :)

Ya thats what I was taking about & it would be better if lines 9 to 15 get inside do while loop.

And perhaps every case needs a do while!!

This is what you do when your bored ?!
I suggest you try learning the Win32 API to be able to make proper window applications, and then mabey move on to MFC when you get the hang of that. From there you should be able to make basic games / animation. Anything is more fun than this ^.^

Start with this tutorial
http://www.winprog.org/tutorial/

commented: Great link +1

> Anything is more fun than this ^.^
Everyone has a different idea of what's fun. For example, Edward is bored to tears when forced to write "proper window applications" in C++. ;) The nice thing about C++ is that we can all do our own thing and still have a blast.

Ok, but I get the feeling he would be more interested in using graphics considering we are very similar ages (14-15) and seems to enjoy messing around and making games, quite like me :P . I especially think he would enjoy directX if he were a little more experienced in programming, even though it might be abit advanced for him (im also having a bit of a hard time learning it). But like you sead Everyone has a different idea of what's fun, so I might be completely wrong :icon_cheesygrin:

This is what you do when your bored ?!
I suggest you try learning the Win32 API to be able to make proper window applications, and then mabey move on to MFC when you get the hang of that. From there you should be able to make basic games / animation. Anything is more fun than this ^.^

Start with this tutorial
http://www.winprog.org/tutorial/

After 3 quarters of java I am tired of dealing with GUI's. There's just no way I can will myself to do it in C++ for any reason other than to learn the syntax involved with C-GUI's.

so I might be completely wrong

You are not completely wrong:). Cause I like it!!! I'll give you a rep just for that link

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.