If the user inputs a name less than six characters the programprompts them to do
ID: 3614337 • Letter: I
Question
If the user inputs a name less than six characters the programprompts them to do it again and tells them that they should input aname more than six characters long. My problem is that after thatwhen the user inputs a name more than six characters the loopcontinues it does not stop. How can solve this problemimport javax.swing.*;
public class length
{
public static void main (String []nyasha)
{
String aString =JOptionPane.showInputDialog("Whats your name");
int length =aString.length();
int num=6;
while ( length<num)
{
JOptionPane.showMessageDialog(null,"Enter a namemore than six characters long");
aString =JOptionPane.showInputDialog("Whats your name");
}
}
}
Explanation / Answer
import javax.swing.*; public class LengthString { public static void main (String []nyasha) { String aString =JOptionPane.showInputDialog("Whats your name"); int length =aString.length(); int num=6; while ( lengthRelated Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.