the following program prompts the user with the following menu :
What would you like to do?
1.print the contents of the database
2.find all the songs on a particular album
3.quit
Please enter 1, 2, or 3.
Everything works fine but i cannot figure out how to keep prompting the user with this menu after each input. for example, if u run the program and type in 1 the program ends. how do i keep the prompt up?
Heres a section of my code...
[CODE=java] int choice;
choice = Console.readInt (
"What would you like to do?\n"
+ "1. print the contents of the database\n"
+ "2. find all the songs on a particular album\n"
+ "3. quit\n"
+ "Please enter 1, 2, or 3.\n");
if (choice==1)
{
int c = 0;
while (c < count)
{
System.out.prin tln(songs[c] + "--" + artists[c] + "--" +
albums[c] + "--" + years[c] + "--" + comments[c]);
c = c + 1;
}
}
else if (choice==2)
{
String albumschoice = Console.readStr ing("Enter album");
albums[0]="jagged little pill"; songs[0]="You oughta know, Head over feet, and You learn";
albums[1]="made in heaven"; songs[1]="heaven for everyone";
albums[2]="zooropa"; songs[2]="stay (far away, so close!)";
int i=0;
char found = 'n';
while (found =='n'&& i<=2)
{
if (albumschoice.e quals(albums[i]) )
{
System.out.prin tln("The songs for " +albums[i] + " are " +songs[i]);
found = 'y';
}
else
{
i = i+1;
}
}
if (found =='n')
{
System.out.prin tln(albumschoic e+ "is not in the database");
}
}
else if (choice==3)
System.out.prin tln("Have a nice day!");
}
}[/CODE]
...thanks
What would you like to do?
1.print the contents of the database
2.find all the songs on a particular album
3.quit
Please enter 1, 2, or 3.
Everything works fine but i cannot figure out how to keep prompting the user with this menu after each input. for example, if u run the program and type in 1 the program ends. how do i keep the prompt up?
Heres a section of my code...
[CODE=java] int choice;
choice = Console.readInt (
"What would you like to do?\n"
+ "1. print the contents of the database\n"
+ "2. find all the songs on a particular album\n"
+ "3. quit\n"
+ "Please enter 1, 2, or 3.\n");
if (choice==1)
{
int c = 0;
while (c < count)
{
System.out.prin tln(songs[c] + "--" + artists[c] + "--" +
albums[c] + "--" + years[c] + "--" + comments[c]);
c = c + 1;
}
}
else if (choice==2)
{
String albumschoice = Console.readStr ing("Enter album");
albums[0]="jagged little pill"; songs[0]="You oughta know, Head over feet, and You learn";
albums[1]="made in heaven"; songs[1]="heaven for everyone";
albums[2]="zooropa"; songs[2]="stay (far away, so close!)";
int i=0;
char found = 'n';
while (found =='n'&& i<=2)
{
if (albumschoice.e quals(albums[i]) )
{
System.out.prin tln("The songs for " +albums[i] + " are " +songs[i]);
found = 'y';
}
else
{
i = i+1;
}
}
if (found =='n')
{
System.out.prin tln(albumschoic e+ "is not in the database");
}
}
else if (choice==3)
System.out.prin tln("Have a nice day!");
}
}[/CODE]
...thanks
Comment