Exiting a while loop using a String?
I'm trying to make the program read in a list of name and ages (using JOptionPane). It's supposed to quit the loop when the name entered is "quit".
I learned to use ".equals" instead of "==" or "!=", but now when I run the program, it doesn't look like it's doing anything. I'm not sure what to do.
Also i'm trying to assign a name to a new name if the age is greater than the last one entered. I'm not quite sure if the way i have it set up will work.
Any help will be greatly appreciated.
----------------------------------------------------------------------
Code:
import javax.swing.JOptionPane;
public class Perrine_Oldest {
public static void main(String[] args){
int l, m, n, o, p, q, r, s, t, newage;
String Quit, quit, rawr, name, age, x, z, a, b, c;
name = "rawr";
l = 1;
while(!name.equalsIgnoreCase("quit"));{
name = JOptionPane.showInputDialog(null, "Enter the name of person " + l + ":");
age = JOptionPane.showInputDialog(null, "Enter the age of person " + l + ":");
n = Integer.parseInt( age );
rawr = "sigh";
if (n >= n){
name = rawr;}
l = l + 1;}
JOptionPane.showMessageDialog(null, "The oldest person is " + rawr + ".");
System.exit(0);
}}
Moderator Edit: code tags added so that the code will retain its formatting and be more readable