I am having problems figuring out how to get the results from the strings and then give myself the option to sort through them alphabetically (or numerically). I have the code to the point where it shows the input data but don't know where to go from there. I'm fairly new to java so I don't even know if I'm doing the first part right. I have looked in to sort options with Arrays but am not to sure how to use them (or if I have done it right to allow myself to use them). Any help would be appreciated. Below is a copy of my code.
The questions I am trying to solve is "Your program should then use a menu that allows the user to display, search and exit. Display should display the list of the entries, sorted by last name, first name, or birth-date as requested by the user. Search should search for a specific entry by a specific field (last name, first name or birth-date) as requested by the user."
import javax.swing.JOptionPane;
public class Program2
{
//Loop #
public static void main(String [] args)
{
int Runs;
do{
String runQuestion = JOptionPane.showInputDialog(null, "Number of patients to enter in? (1-2)", "Total # Of Patients", JOptionPane.QUESTION_MESSAGE);
Runs = Integer.parseInt(runQuestion);
if( Runs < 1 || Runs > 2)
{ //Small test numbers for now
JOptionPane.showMessageDialog(null, "Please pick a number between 1 and 2", "Wrong Number Chosen", JOptionPane.INFORMATION_MESSAGE);
}
}
while(Runs < 1 || Runs > 2);
Questions(Runs);
}
//Data Gathering Questions
public static void Questions(int Runs)
{
for(char index = 0;index < Runs;index ++)
{
//Questions
String firstName = JOptionPane.showInputDialog(null, "Patients First Name?", "First Name", JOptionPane.QUESTION_MESSAGE);
String lastName = JOptionPane.showInputDialog(null, "Patients Last Name?", "Last Name", JOptionPane.QUESTION_MESSAGE);
String dateBirth = JOptionPane.showInputDialog(null, "Patients Date of Birth?", "DOB", JOptionPane.QUESTION_MESSAGE);
String firstSort = String firstName;
//Data Table print list
System.out.println(firstName + " " + lastName + " " + dateBirth);
}
}
}