I have a problem here.

Eg,

do {

method1();
method2();
method3();

while(repeat() );

how do i write the repeat() ??

It's needs to take in user inputs (eg, yes,no,y,n) and convert them into boolean.
If input is yes/y, then it will repeat everything again.
If input is no/n,then it will end the whole thing.

Recommended Answers

All 4 Replies

how do i write the repeat() ??

Investigate JOptionPane.showConfirmDialog() if you are working on a GUI proggy.

If it's a console proggy, it's a lil bit more complicated, and I am a lazy writer. :D

public boolean repeat()
{
    //ask user for answer YES, NO
    //if response is yes, return true
    //if not yes, then return false        
}

Can i know how to convert what the user inputs into boolean expression ?

Simple way:


String input = //get input from user

if (input.equals("yes"))

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.