// Find total, count, print average while 'Y' loop package somePackage; import java.util.*; public class InchesTable { public static void main(String[] args) { Scanner keyboard=new Scanner(System.in); //do just once int count=0, total=0, num; String answer; System.out.print("Are there any numbers (Y or N):"); answer=keyboard.next(); char ch=answer.charAt(0); while (ch=='Y' || ch=='y') { System.out.print("Enter number: "); num=keyboard.nextInt(); total+=num; count++; System.out.print("Are there more numbers (Y or N):"); answer=keyboard.next(); ch=answer.charAt(0); }//while System.out.println("Count="+count); System.out.println("Total="+total); if (count > 0) // avoid dividing by zero! System.out.println("Average="+1.0*total/count); }//main }//class