Im trying to make an array that just lists out some values, its the number of items sold in a day in a shop. and then, total those items in a seperate printf.
Heres my code so far, i also seem to have an issue where it just ignore my 0 , it will only show 1,2,3,4,5,6...ignoring the 0 totally.......heres the code...
public class InitArray5
{
public static void main(String args[])
{
final int SALES_LENGTH=6; //declare constant
int sales[]=new int[SALES_LENGTH];
int sale[]={13,8,22,17,24,15,23};
int counter=0;
int sum;
sum=0;
System.out.printf("%2s%8s\n","index","value");
while(counter<sales.length)
{
counter=counter+1;
sum=sum+sale[counter];
System.out.printf("%s%8s\n",counter,sale[counter]);
}
}
}