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
Solved

Java "while" loop

Posted on 1998-03-23
2
178 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
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: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

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

Suggested Solutions

This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
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 will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…

829 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