Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Java "while" loop

Posted on 1998-03-23
2
Medium Priority
?
196 Views
Last Modified: 2010-04-16
I am working on a project for class and I need to construct a "while" statement.  My program accepts two numbers from the user and I need a way to allow them to enter another pair of numbers if they choose (using a "while" statement).  How can I use a "while" loop to perform some kind of "Do you want to try again, y or n" action?
0
Comment
Question by:regent
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 4

Accepted Solution

by:
rafistern earned 400 total points
ID: 1233733
Try this

String answer="no";

while(answer.equals("no"))
{
[Input two numbers]

[Do you want to try again? This will involve entering a new value for 'answer']
}

The bits in [] are the code you have to write.

Rafi
0
 

Author Comment

by:regent
ID: 1233734
Rafi,

I really appreciate your help.

Thomas
0

Featured Post

The top UI technologies you need to be aware of

An important part of the job as a front-end developer is to stay up to date and in contact with new tools, trends and workflows. That’s why you cannot miss this upcoming webinar to explore the latest trends in UI technologies!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

INTRODUCTION Working with files is a moderately common task in Java.  For most projects hard coding the file names, using parameters in configuration files, or using command-line arguments is sufficient.   However, when your application has vi…
In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
Suggested Courses

661 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question