Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Java "while" loop

Posted on 1998-03-23
2
Medium Priority
?
198 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
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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…
Suggested Courses

879 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