Hi!
Sorry in advance if this is really long or a bad question, I am new to Java and object-oriented programming and easily confused.
My class very briefly in the first assignment like.... 4 weeks ago touched on the JOptionPane, but I can't find anything I need from the book or from the first assignment except the basics, so I was hoping someone could help!
This is the assignment:
"Write an application containing three parallel arrays that hold 10 elements each. The first array hold four-digit student ID numbers, the second array holds first names, and the third array holds the students’ grade point averages. Use dialog boxes to accept a student ID number and display the student’s first name and grade point average. If a match is not found, display an error message that includes the invalid ID number and allow the user to search for a new ID number."
I am stuck on the error message, mainly: I have not worked in JOptionPane more than once, and what you'll see in my code is basically all I've ever done.
Furthermore, what I have doesn't return the correct values: the dialog box returns the correct text, but the wrong format and a bunch of weird symbols instead of the corresponding FirstName and GPA ("First name: [Ljava.lang.String;@57e1b0cGPA:[D@4232c52b").
This is my code so far:
import javax.swing.JOptionPane;
public class Assignment1 {
public static void main(String[]args) {
int [] StudentID = {1234, 5678, 9101, 1213, 1415, 1617, 1819, 2021, 2223, 2425};
String[] FirstName = {"Bob", "Joe", "Jane", "John", "Roman", "Billy", "Casy", "Kylie", "Raimy", "Abby"};
double [] GPA = {3.4, 3.6, 2.1, 1.2, 4.0, 3.7, 1.0, 3.7, 3.9, 3.4};
JOptionPane.showInputDialog(null, "Enter student ID");
JOptionPane.showMessageDialog(null, "First name: " + FirstName + "GPA: " + GPA);
}
}
I've attempted if....else, and a do....while, but I'm really confused by how to check if the user-input number = the StudentID