Note that there are some explanatory texts on larger screens.

plurals
  1. POJava Two Dimensional Array Student Record Input
    text
    copied!<p>I'm studying Java and I've been working on this exercise for 2 days now. I've foraged the internet for answers but I can't seem to find the best one to solve my problem which are: 1. How to store the Strings input (like fName, mName //or am i doing this right?) into a two dimensional array. I've seen some sample programs with the syntax like:</p> <pre><code>fName = fName.getText(); lName = lname.getText(); </code></pre> <p>but they don't seem to fit with what i'm trying to code and i can't go around it either coz im just a begginer.</p> <ol> <li>How to print all the input after all the loop thing. Like when the user input "4" in the "Enter number of students", 4 student information will be printed.</li> </ol> <p>Here is my initial non-working code:</p> <pre><code>import java.io.*; public class Main { public static void main(String[] args)throws IOException{ BufferedReader datain = new BufferedReader (new InputStreamReader (System.in)); String fName, lName, course, yrLevel, bDate; int age; int arr [] []; int size; System.out.print("Enter number of students: \n"); size = Integer.parseInt(datain.readLine()); arr = new int [size][]; for(int a = 0; a &lt; arr.length; a++){ System.out.print("Enter first name: \n"); fName = datain.readLine(); /*insert code here to store fName to two dimensional array like this one? arr [0] = new int [a]; */ System.out.print("Enter last name: "); lName = datain.readLine(); System.out.print("Enter course: "); course = datain.readLine(); System.out.print("Enter year level: "); yrLevel = datain.readLine(); System.out.print("Enter age: "); age = Integer.parseInt(datain.readLine()); } /* desired output be like: Student 1 Name: Bat Man Year Level: Graduate School Birthdate: Feb. 20, 2012 Age: 7 Student 2 Name: Super Man Year Level: Masteral Birthdate: Jan. 1, 2012 Age: 8 */ System.out.println("Name: " +arr[0][0] + " " + arr[0] [1]); //just me showing my non-working idea of printing them. } } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload