So, I would like to know how to limit the loops.
This is my problem.
My problem is that I don't know how to exit this program after 10 iterations/loops.
(i know this is wrong
import javax.swing.JOptionPane;
public class Main {
public static void main(String[] args) {
String x;
String y;
int z=5;
do
x=
JOptionPane.showInputDialog("Enter any number other than "+z);
while(!x.equals ("5"));
if (x.equals ("5"))
JOptionPane.showMessageDialog(null, "Hey! you weren't suppose to enter number "+z+"!");
JOptionPane.showMessageDialog(null, "Wow, you're more patient than I "
+ "am, You win");
}
}

New Topic/Question
Reply



MultiQuote




|