Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Computer Engineering Expert

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.

Computer Engineering, Engineering

  • Category:- Computer Engineering
  • Reference No.:- M9651859

Have any Question?


Related Questions in Computer Engineering

Describe a ping of death attack as an attack that causes

Describe a ping of death attack as an attack that causes the victim computer to freeze and malfunction.

Question part 2 1using the major business performance

Question: Part 2: 1. Using the major business performance management (BPM) processes, describe the general process of how the case study organization will collect data that are relevant to the following: • Strategize • P ...

Systems analysis projectpersonal trainer inc owns and

Systems analysis project Personal Trainer, Inc. owns and operates fitness centers in a dozen Midwestern cities. The centers have done well, and the company is planning an international expansion by opening a new "superce ...

When is a subclass a subclasswhen programming or solving

When is a Subclass a Subclass When programming, or solving any sort of problem for that matter, abstraction plays a key role in the decision-making process. It allows you to remove irrelevant details in order to understa ...

Say that a processor addresses bytes with 64 bits addresses

Say that a processor addresses bytes with 64 bits addresses, has 8 byte words, and 1024 cache entries that are each 8 words long. a) How would the bits of the address be used to indicate the set, line, word and byte? b) ...

How could legislation impact on operations within your

How could legislation impact on operations within your organisation in relation to innovation, project management, and operational planning? Briefly outline any relevant requirements (e.g. intellectual property, WHS).

Reading the biographybook where the body meets memory by

Reading the Biography Book : "Where the Body Meets Memory" by David Mura Questions: The internment camps were a very painful experience for Japanese Americans. They were also a very important and awkward chapter in Ameri ...

Question suppose that in game of chance you bet an initial

Question : Suppose that in game of chance, you bet an initial amount of money, and every time you play, the money is doubled with probability p and halved with probability 1 - p. (a) What value of p gives you an expected ...

Short answer essaygiven a requirement to integrate wdas

Short answer essay Given a requirement to integrate WDAs into an Enterprise Intranet, what are 2 applications that would be candidates for that, and illustrate strategies/methodologies to accomplish that.

Question suppose you have created a program that creates

Question : Suppose you have created a program that creates instances of different types of cars. Now you are creating a program that keeps track of different types of cars. Choose the abstract classes and concrete classe ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As