I am writing a program for my Java class in which a user will enter up to 10 First and Last Names and the birthdate sorted in different manners, but for right now my main concern is even being able to print out the arrays. Heres my code...
CODE
import javax.swing.JOptionPane;
import java.util.ArrayList;
import java.util.*;
public class Program_02
{
public static void main(String[] args)
{
//A count for the total number of people the user would like to enter into the program
int total_names;
do
{
String Run_Question = JOptionPane.showInputDialog(null, "How many names would you like to enter" +
" into the program?(Up to 10 max)", "How Many?", JOptionPane.QUESTION_MESSAGE);
total_names = Integer.parseInt(Run_Question);
//If the user enters more names or less names for example a negative or a number larger than 10
//This error is displayed.
if(total_names < 0 || total_names > 10);
{
JOptionPane.showMessageDialog(null, "That is not a valid amount of names", "Error!",
JOptionPane.INFORMATION_MESSAGE);
}
}while(total_names < 0 || total_names > 10);
{
for(int index = 0;index < total_names;index ++)
{
//Establishes strings to hold the data
String[] First_Name_String = new String[15];
String[] Last_Name_String = new String[15];
String[] Birth_Date_String = new String[15];
First_Name_String[index] = JOptionPane.showInputDialog(null, "What is the First Name?", "First Name", JOptionPane.QUESTION_MESSAGE);
Last_Name_String[index] = JOptionPane.showInputDialog(null, "What is the Last Name?", "Last Name", JOptionPane.QUESTION_MESSAGE);
Birth_Date_String[index] = JOptionPane.showInputDialog(null, "What is the Birth Date(MM/DD/YYYY)?", "Birth Date", JOptionPane.QUESTION_MESSAGE);
printFirst(First_Name_String, index);
}
}
}
public void printFirst(String[] First_Name, int count)
{
JOptionPane.showMessageDialog(null, First_Name[count], "Printing results",JOptionPane.INFORMATION_MESSAGE);
}
}
non-static method printFirst(java.lang.String[],int) cannot be referenced from a static context this is the error i get on line 38
CODE
printFirst(First_Name_String, index);
If I can atleast get it to print or find a more efficient way to get it to print I can move on to sorting and printing.