User to enter a series of one-digit numbers


Write a program that asks the user to enter a series of one-digit numbers (you will need to do error checking). When they have finished (you will have to determine how the user indicates they are finished), print out how many of each number the user entered. There must be two methods. Name your program Lab10_ex2.java.
Here is a sample output if the user entered 0,7,7,2,7,10:
Hint: Use an array to hold an accumulator (counter) for each digit.
Note: Do not output a value of 0 for the number of digits entered.
Enter a one-digit number or 10 to exit: 0 [enter]
Enter a one-digit number or 10 to exit: 7 [enter]
Enter a one-digit number or 10 to exit: 7 [enter]
Enter a one-digit number or 10 to exit: 2 [enter]
Enter a one-digit number or 10 to exit: 7 [enter]
Enter a one-digit number or 10 to exit: 10 [enter]
You entered 1, 0(s)
You entered 1, 2(s)
You entered 3, 7(s)
Arrays of Reference Variables
You can create arrays of any data type. If the array is formed from data that uses reference variables (like Strings, for instance) then the array declaration takes two steps. The first step creates the collection of reference variables. The second step initializes each reference variable in the collection prior to using the array. If the array were an array of Strings, then the code could look something like:
String [] strings = new String[5];
strings[0] = "One";
strings[1] = "Two";
strings[2] = "Three";
strings[3] = "Four";
strings[4] = "Five";
It is possible to initialize the array at declare time (just like any other array) or to read values into each element instead of assigning a value to each element as in the sample code above.

Request for Solution File

Ask an Expert for Answer!!
Basic Computer Science: User to enter a series of one-digit numbers
Reference No:- TGS0144315

Expected delivery within 24 Hours