Hey all,
so i am having trouble figuring out how to add a value (that i have just prompted the user for) to an array..
___
import java.io.*;
import java.util.ArrayList;
public class prac7Rainfall1
{
public static void main(String args[]) throws IOException
{
int[] rainArray; // declare an array of integers
rainArray = new int[12];// create an array of integers
String myString;
//Reading from the keyboard
BufferedReader myInput = new BufferedReader(new InputStreamReader( System.in));
// assign a value to each array element and print
for (int i = 0; i < rainArray.length; i++) {
rainArray[i] = i;
System.out.print("Enter amount for Month 1: ");
myString = myInput.readLine (); //need to insert some code here that will allow me to add value to array
System.out.println(rainArray[i] + " ");
}
System.out.println();
}
}
thanks
so i am having trouble figuring out how to add a value (that i have just prompted the user for) to an array..
___
import java.io.*;
import java.util.ArrayList;
public class prac7Rainfall1
{
public static void main(String args[]) throws IOException
{
int[] rainArray; // declare an array of integers
rainArray = new int[12];// create an array of integers
String myString;
//Reading from the keyboard
BufferedReader myInput = new BufferedReader(new InputStreamReader( System.in));
// assign a value to each array element and print
for (int i = 0; i < rainArray.length; i++) {
rainArray[i] = i;
System.out.print("Enter amount for Month 1: ");
myString = myInput.readLine (); //need to insert some code here that will allow me to add value to array
System.out.println(rainArray[i] + " ");
}
System.out.println();
}
}
thanks