Hey, this is my first java program. I am trying to print my original list of ages, but I can not figure it out. Please help! I have part b and part c already done. Any help is appreciated
a) print original list of ages
b) number of occurrences of age 10
c) print list of ages removing age 10
import java.io.* ;
class BagofAges
{
public static void main(String args[]) throws IOException
{
DataInputStream in=new DataInputStream(System.in);
int ages[]=new int[100];
int i=0,k=0,kcount=0;
do
{
System.out.print("enter the age of your next family member or -1 to terminate:" );
k= Integer.parseInt(in.readLine());
if(k==10)
{
kcount++; //counts the no of occurrence of age 10 and do not add it to the ages[] array
}
else if (k!=-1) //saves all values in ages[] except for -1 and 10
{
ages[i++] =k;
}
}
while (k!=-1);
System.out.println("Number of age 10 occurrence:"+kcount);
System.out.println("List of Ages");
for(int z=0;z<i;z++)
{
System.out.println(ages[z]);
}
}
}