474,048 Members | 45,674 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.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
Jul 17 '05 #1
2 1713
"Donna" <Do********@blu eyonder.co.uk> wrote in message
news:Pg******** **********@fe2. news.blueyonder .co.uk...
[...]
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********@blu eyonder.co.uk> wrote in message
news:Pg******** **********@fe2. news.blueyonder .co.uk...
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
2748
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
3902
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
2119
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. i don't really understand what is expected, or really what the question means. could anyone explain what the question's after please? any help much appreciated. thanks, ben. Prove an upper bound on the number of machine instructions required to
8
5437
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 `'}'' 'else if (choice == 27) exit(0) } }' Here is my program (Simple loop to display currency equivalencies based
16
1607
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 that outputs on to the console a message like "please enter some text" then when the user enters text it gets stored in a char array or whatever is best. I then want to check that the array is no longer than 25 chars ( i dont know if malloc is...
0
5600
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 ******************************************************** For this teeny job, please refer to: http://feeds.reddit.com/feed/8fu/?o=25
1
6158
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. Please follow the specifications for assignment 3 as described below otherwise points will be taken off. Input from a file Please create an input file named input.txt using a text editor like notepad or the Visual C++ editor and put the following...
9
2536
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 *after* calling increase_arrays(), I received segmentation fault. I tried to step it through gdb, and I found out that after calling increase_arrays(), words's original value is modified, and if I tried to access it, I get <address 0x11 out of...
2
2483
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 somebody point me in the right direction. how do I get the individual name so that I can insert into the group table,
0
10557
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10358
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
12168
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
11616
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
12055
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10333
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
8719
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
1
5432
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
4953
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.