STACK PROJECT!

can somebody help us with our project?
how to create a menu using stack? #include <stack>

this would be the output:

=====menu=====
category
a. hiphop
b. rnb
c. opm
d. rock
e. lovesong
choose:

(each category has 5 songs)
help me plssssss :((((
this is what weve got, but its incomplete & definitely wrong coz its not stack -__-


#include<iostream>
#include<string>
#include<stack>
using namespace std;

void showMenu();
void mmm();
char gc();
char hh();

int main()
{
bool quit = false;

while (!quit)
{
showMenu();
char ch = gc();
switch(ch)
{
case 'A':
{
mmm();
int pp = hh();
switch(pp)
{
case 1:
//
break;
case 2:
//
break;
case 3:{}
//
break;
case 4:
//
break;
case 5:
//
break;
case 6:
//
break;
}
}

// handle choice A
break;
case 'B':
// handle choice B
break;
case 'C':
// handle choice C
break;
case 'D':
//D
break;
case 'E':
//E
break;
case 'F':
quit = true;
break;
}
}

return 0;
}


char gc()
{
cout << "\nEnter choice: ";
char ch;
cin >> ch;
cin.ignore(255, '\n');

return toupper(ch);
}

void showMenu()
{
cout<<"\nA\tHiphop";
cout<<"\nB\tRNB";
cout<<"\nC\tOPM";
cout<<"\nD\tRock";
cout<<"\nE\tLoveSong";
cout<<"\nF\tExit";
}

char hh()
{
cout << "\nEnter choice: ";
char hh;
cin >> hh;
cin.ignore(255, '\n');
return 0;
}

void mmm()
{
system("CLS");
cout<<"1.hehe"<<endl;
cout<<"2.huhu"<<endl;
cout<<"3.lol"<<endl;
cout<<"4.nye"<<endl;
cout<<"5.haha"<<endl;
cout<<"6.Back to menu"<<endl;
}




Hello dendimon,

Please edit your post and enclose the code in code tags. Use the <> button to the right of the message window. This makes your code easier to read.

You really do not need the {} around everything in case A:, but they are OK if you leave them.

The line that reads int pp = hh() pp is defined in the wrong place. Put it at the top after the definition for quit. Then the code will compile and work.

Your code shows no attempt to use a stack. You need to code for the stack before we can help you. I am not familiar with the sue of a stack so I did a google search on std stack and you should find this helpful http://www.dreamincode.net/forums/topic/57497-stl-stack/ . When you get farther and get stuck let us know.

Hope that helps,

Andy

P.S. Starting a second thread is just confusing to everyone and you could miss an answer.
Last edited on
Topic archived. No new replies allowed.