Hi, I need help with my java program. I am new with java, so go easy on me if this is a dumb question.
Ok the question is
"You will complete two methods for this exercise. The headers (and a comment that describes each one) are below: Create a main method that asks the user for the length of the array, uses readArray to read in the array, and uses printArray to print the resulting array."
[PHP]public static void readArray(int a[], int length)
//This method reads "length" values into array a
public static void printArray(int a[], int length)
//This method prints the values from array a[/PHP]
The program that I am working with is:
[PHP]// Example9.java
import java.util.Scann er;
public class Example9{
public static void main(String[] args){
Scanner sc = new Scanner(System. in);
final int MAX = 5;
int[] a = new int[MAX];
int i = 0;
while (i < MAX){
System.out.prin t("Enter a number: ");
int n = sc.nextInt();
a[i] = n;
++i;
}
System.out.prin tln("The data are:");
i = 0;
while (i < MAX){
System.out.prin tln(a[i]);
++i;
}
}
}[/PHP]
Ok the question is
"You will complete two methods for this exercise. The headers (and a comment that describes each one) are below: Create a main method that asks the user for the length of the array, uses readArray to read in the array, and uses printArray to print the resulting array."
[PHP]public static void readArray(int a[], int length)
//This method reads "length" values into array a
public static void printArray(int a[], int length)
//This method prints the values from array a[/PHP]
The program that I am working with is:
[PHP]// Example9.java
import java.util.Scann er;
public class Example9{
public static void main(String[] args){
Scanner sc = new Scanner(System. in);
final int MAX = 5;
int[] a = new int[MAX];
int i = 0;
while (i < MAX){
System.out.prin t("Enter a number: ");
int n = sc.nextInt();
a[i] = n;
++i;
}
System.out.prin tln("The data are:");
i = 0;
while (i < MAX){
System.out.prin tln(a[i]);
++i;
}
}
}[/PHP]
Comment