Java Programming Help, Multi Dimensional Array?
-
I making a program that uses a multi dimensional array. Its a program where you can input a student's adress, ID number and name(first multi dimensional array) and a student's prelim, midterm and final grade(second multi dimensional array). Our instructor told us that we can only use two initialized values for the multi dimensional array(MUST HAVE EXACTLY ONLY [][] brackets and not [][][] or [][][][] brackets) for both arrays, and it must not exceed two or become less than two. The data we need to input for both arrays is three(Name, adress and id number for the first array. prelim, midterm and final grade for the second array), how will i suppose to input the three pieces of data, when there are only two values that are initialized in the multi dimensional array?
-
Answer:
make first entry the id number, the second entry a 2-dimensional array. thus for instance for 4 entries: Object[][] array = new Object[4][]; array[0][0] = new String[][]() { "name", "adress street"}; array[1][0] = new String[][]() { "name", "adress street"}; array[2][0] = new String[][]() { "namewww", "adress street"}; array[3][0] = new String[][]() { "name", "adress street"};
gjmb1960 at Yahoo! Answers Visit the source
Other answers
first array is may be String[][] where the indices are the students' IDs and addresses (assuming address is an integer) and the data inside the array is the students' names. second array may be int[][] where the indices are the prelim and midterms and the data inside the array is the final grade. I'm not claiming it's a good idea for a data structure to store this kind of data but if that's what the instructor wants ...
Insaan
Related Q & A:
- How to start programming a game in java?Best solution by Game Development
- Computer Programming help?Best solution by Yahoo! Answers
- Computer Science Java Programming?Best solution by AllExperts
- Is java or visual basic a machine level, low level, high level or binary level programming language?Best solution by Quora
- Help on Lisp programming question.Best solution by Yahoo! Answers
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
For every problem there is a solution! Proved by Solucija.
-
Got an issue and looking for advice?
-
Ask Solucija to search every corner of the Web for help.
-
Get workable solutions and helpful tips in a moment.
Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.