473,326 Members | 2,136 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

Help with WHILE loops required please

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.displayAll();
break;
case '2':
thisStudent = myGroup.findThisStudent(myNumber);
thisStudent.display();
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
Jul 17 '05 #1
2 1682
"Donna" <Do********@blueyonder.co.uk> wrote in message
news:Pg******************@fe2.news.blueyonder.co.u k...
[...]
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.

Can what be done with a char? You know that chars work in a switch statement. In
fact a char is an integral type. Anything you can do with an int, you can do
with a char.
Jul 17 '05 #2
"Donna" <Do********@blueyonder.co.uk> wrote in message
news:Pg******************@fe2.news.blueyonder.co.u k...
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.

[...]
Also, please do not multipost. And while you're at it, confine your posts to
comp.lang.java.help.
Jul 17 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

24
by: Andrew Koenig | last post by:
PEP 315 suggests that a statement such as do: x = foo() while x != 0: bar(x) be equivalent to while True:
9
by: Michael Dekson | last post by:
Hello, Can I exe file made in Microsoft Visual C++ decompile into source code. If it is possibly please tell me how. Thanks
2
by: ben | last post by:
hello, i'm following an algorithm book and am stuck on an early excersise in it, not because of the c programming side of it or even the algorithm side of it, i don't think, but because of maths....
8
by: drose0927 | last post by:
Please help! I can't get my program to exit if the user hits the Escape button: When I tried exit(EXIT_SUCCESS), it wouldn't compile and gave me this error: Parse Error, expecting `'}''...
16
by: hoggmeister | last post by:
Hi, Im new to C coming from a java background. I having difficulty adjusting to C and was hoping someone could help me with a little simple code to get started. I would like a little program...
0
by: gunimpi | last post by:
http://www.vbforums.com/showthread.php?p=2745431#post2745431 ******************************************************** VB6 OR VBA & Webbrowser DOM Tiny $50 Mini Project Programmer help wanted...
1
by: al2004 | last post by:
Write a program that reads information about youth soccer teams from a file, calculates the average score for each team and prints the averages in a neatly formatted table along with the team name....
9
by: weidongtom | last post by:
Hi, I've written the code that follows, and I use the function add_word(), it seems to work fine *before* increase_arrays() is called that uses realloc() to allocate more memory to words. But...
2
by: lhiregoudar | last post by:
hi, I am trying to 1)get all the names of a table that match another table 2)while count=0, then I want to insert into another table 'group' after getting its key. I am totally lost, can...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.