I am attempting a distance learning course in Java but am having problems
with a task. I have completed the simple little program as listed below.
public class Results
{
private static String version =
"Module Results (version Exercise 1-3)";
static Group myGroup = new Group();
public static void main(String args[])
{
char selection;
String myNumber = "0490011";
Student thisStudent;
selection = IO.readChar
(version + "\n\nPlease input \n1. To display all student
results\nor\n2. To display results for Student 0490011");
switch (selection)
{
case '1':
myGroup.display All();
break;
case '2':
thisStudent = myGroup.findThi sStudent(myNumb er);
thisStudent.dis play();
break;
default:
IO.display (version,
"You didn't select 1 or 2");
}
System.exit(0);
}
}
My next task is too insert a while statement so that the user can repeat the
menu options as often as required. The text book that I have got
explains a while statement as follows.
BEGIN
continuing = true (I assume something like char = 1 or
2)
WHILE continuing (While char = 1 or 2 diplay menu)
display menu
get selection
SWITCH selection
and so on.
Can this be done with a char or do I need to use the input selection as an
integer.
Many thanks, Any help welcome.
Donna
with a task. I have completed the simple little program as listed below.
public class Results
{
private static String version =
"Module Results (version Exercise 1-3)";
static Group myGroup = new Group();
public static void main(String args[])
{
char selection;
String myNumber = "0490011";
Student thisStudent;
selection = IO.readChar
(version + "\n\nPlease input \n1. To display all student
results\nor\n2. To display results for Student 0490011");
switch (selection)
{
case '1':
myGroup.display All();
break;
case '2':
thisStudent = myGroup.findThi sStudent(myNumb er);
thisStudent.dis play();
break;
default:
IO.display (version,
"You didn't select 1 or 2");
}
System.exit(0);
}
}
My next task is too insert a while statement so that the user can repeat the
menu options as often as required. The text book that I have got
explains a while statement as follows.
BEGIN
continuing = true (I assume something like char = 1 or
2)
WHILE continuing (While char = 1 or 2 diplay menu)
display menu
get selection
SWITCH selection
and so on.
Can this be done with a char or do I need to use the input selection as an
integer.
Many thanks, Any help welcome.
Donna
Comment