Solved

Java "while" loop

Posted on 1998-03-23
2
153 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 100 total points
Comment Utility
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
Comment Utility
Rafi,

I really appreciate your help.

Thomas
0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
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 …
Viewers learn about the “while” loop and how to utilize it correctly in Java. Additionally, viewers begin exploring how to include conditional statements within a while loop and avoid an endless loop. Define While Loop: Basic Example: Explanatio…

744 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now