Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to return multiple numbers in an array, in a single print statement
    text
    copied!<pre><code>public class Main { public static void main(String[] args) { java.util.ArrayList&lt;StudentDataArray&gt; info = new java.util.ArrayList&lt;StudentDataArray&gt;(); int amountOfPeople = KeyboardInput.promptForInt("Enter how many people you plan to enter into the list."); for(int a=0;a&lt;amountOfPeople;a++) { try { double[] grade = new double[5]; grade[0]=KeyboardInput.promptForDouble("Enter the First grade"); grade[1]=KeyboardInput.promptForDouble("Enter the Second grade"); grade[2]=KeyboardInput.promptForDouble("Enter the Third grade"); grade[3]=KeyboardInput.promptForDouble("Enter the Fourth grade"); grade[4]=KeyboardInput.promptForDouble("Enter the Fifth grade"); info.add(new StudentDataArray(KeyboardInput.promptForString("Enter the First Name"),KeyboardInput.promptForString("Enter the Last Name"),grade,KeyboardInput.promptForChar("Enter the Final Grade"))); }catch(IllegalArgumentException e){ System.out.println("Hello World :)"); } } for(int b=0;b&lt;amountOfPeople;b++) { System.out.printf("%-10s %-10s %-3f %-3s",info.get(b).getFN(),info.get(b).getLN(),info.get(b).getTS(),info.get(b).getFG()); } } } public class StudentDataArray { private String firstName; private String lastName; private double[] testScore; private char finalGrade; public StudentDataArray(String FN, String LN, double[] TS, char FG) { firstName = FN; lastName = LN; testScore = TS; finalGrade = FG; } public void setFN(String FN) {firstName = FN;}; public void setLN(String LN) {lastName = LN;} public void setTS(double[] TS) {testScore = TS;} public void setFG(char FG) {finalGrade = FG;} public String getFN() {return firstName;}; public String getLN() {return lastName;} public String getTS() { for(int a=0;a&lt;testScore.length;a++) { return testScore[a]+" "; } return null; } public char getFG() {return finalGrade;} } </code></pre> <p>Hey guys, this is my code for all to look at. What im trying to do is to return multiple doubles into one spot in the code. what it will look like is...</p> <p>Ethan Michael 10 20 30 40 50 A</p> <p>where this is all displayed in one statement [10 20 30 40 50]</p> <p>Since I am using a double[] i wasnt sure how to go about this. </p> <p>Thanks guys!</p>
 

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