I'm writing a program that will ask the user for input and then store it into an array until called to the output screen. here is an example of my code so far. I have no idea how to get the input to store in the array.
import java.util.Scanner;
public class Sales
{
//main method begins
public static void main( String[] args )
{
//declaring arrays
int[] salary;
int[] value;
//create arrays
salary = new int [ 10 ];
value = new int [ 11 ];
//init Scanner and get user input
Scanner sc = new Scanner( System.in );
System.out.print("Enter sales amount: " ); //prompt
salary = input.nextInt();
while (salary[0] != -1 )
{
for (int index = 0; index < (salary.length); index++)
{
if ( 0 <= (int)Math.floor((( salary[index] * (.9) + 200 ) * .01 )))
++value[0];
else
++value[(int)Math.floor((( salary[index] * (.9) + 200 ) * .01 ))];
}
System.out.printf( "%s:%20s:\n", "Index", " Value"); //column heading
for (int index1 = 2; index1 < value.length - 1; index1++)
System.out.printf("$%5d-%3d: %10d\n", index1 * 100, index1 * 100 + 99, value[index1]);
for (int index2 =11; index2<= value.length; index2++ )
System.out.printf( "$%5d%5s: \n", index2*100-100, " and over", value[10]);
System.out.print("Enter sales amount: "); //prompt
salary = input.nextInt();
}
} // end main
} // end class Salary
Any help would be greatly appreciated.