Java while loops - selecting a specific variable value from the many entered
<p>I am a little stuck with my coursework in JAVA. Could you help me?</p>

<p>let's say you want to write a program that repetitively asks the names of people and their age and stops when the string FINISH is entered, then prints out the name and the age of the youngest person of all the people entered. And if 2 or more people have the same age, jsut write the name of the last person of that age entered. How can you ask JAVA to select that person, without the use of arrays, but only while loops, if statements and for loops.</p>

<p>Here is the example, starting from the method.</p>

<pre><code>String name = "";

int age = 0;

while (!name.equals ("finish))    

{ 
   name = JOptionPane.showInputDialog ("Give name: ");

   String ageText = JOptionPane.showInputDialog ("Give age: ");

   int age = Integer.parseInt (ageText);    
}

JOptionPane.showMessageDialog ("the yougest person is " + age + ". It's " + name + ".");
</code></pre>

<p>An example run of the program:</p>

<p>Give name: Lucy
Give age: 52</p>

<p>Give name: Paul
Give age: 29</p>

<p>Give name:John
Give age: 28</p>

<p>Give name: Mary
Give age: 31</p>

<p>Give name: finish</p>

<p>The youngest person is 28. It's John.</p>

<p>Please note how string "finish" is not printed out at the end.</p>

<p>I have been thinking trying to find a way of doing that for 8 hours. I beg you help please.</p>

<p>Kind regards,</p>
