Write a program that prompts the user to enter integers in the range 1 to 50 and counts the occurrences of each integer. The program should also prompt the user for the number of integers that will be entered. As an example, if the user enters 10 integers (10, 20, 10, 30, 40, 49, 20, 10, 25, 10), the program output would be:

Answers

Answer 1

Answer:

import java.util.Scanner; public class Main {    public static void main(String[] args) {        int num[] = new int[51];        Scanner input = new Scanner(System.in);        System.out.print("Number of input: ");        int limit = input.nextInt();        for(int i=0; i < limit; i++){            System.out.print("Input a number (1-50): ");            int k = input.nextInt();            num[k]++;        }        for(int j=1; j < 51; j++){            if(num[j] > 0){                System.out.println("Number of occurrence of " + j + ": " + num[j]);            }        }    } }

Explanation:

The solution is written in Java.

Firstly, create an integer array with size 51. The array will have 51 items with initial value 0 each (Line 5).

Create a Scanner object and get user entry the number of input (Line 6-7).

Use the input number as the limit to control the number of the for loop iteration to repeatedly get integer input from user (Line 9-13). Whenever user input an integer, use that integer, k, as the index to address the corresponding items in the array and increment it by one (LINE 11-12).

At last, create another for loop to iterate through each item in the array and check if there is any item with value above zero (this means with occurrence at least one). If so, print the item value as number of occurrence (Line 14-17).


Related Questions

Describe any five GSM PLMN basic services?

Answers

Answer:

Your answer can be found in the explanation below.

Explanation:

GSM is the abbreviation for Global System for Mobile communication. Its purpose is to transmit voice and data services over a range. It is a digital cellular technology.

PLMN is the abbreviation for Public Land Mobile network. It is defined as the wireless communication service or combination of services rendered by a telecommunication operator.

The plmn consists of technologies that range from Egde to 3G to 4G/LTE.

PLMN consists of different services to its mobile subscribers or users but for the purpose of this question, i will be pointing out just 5 of them alongside its definitions.

1. Emergency calls services to fire or police: Plmn provides us with the option to make emergency calls in the event of any accident or fire incident, etc.It is available on devices either when locked or unlocked.

2. Voice calls to/from other PLMN: This entails the putting of calls across to persons we cannot reach very quickly. PLMN helps to connect persons through its network of from other networks thus making communication easier.

3. Internet connectivity: PLMN provieds us with internet services through wifi or bundles that enable us have access to the internet as well as help us communicate with people and loved ones over a distance. Internet service are possble either on GPRS or 3G or 4G networks.

4. SMS service: SMS means short messaging service. This is also know as text messages. PLMN allows us to be able to send short messages to people as oppposed to mails. It is mostly instant and can be sent or recieved from the same PLMN or others.

5. MMS service: Multimedia messaging service whose short form is MMS ccan be descibed as the exchange of heavier messages such as a picture or music or document but not from an email. It is availabel for use from one PLMN to another.

Cheers.

If i wanted to change my phones simcard, does anything need transferring, or is it an easy swap?

Answers

Most likely not but I think you’ll have to log in your account like if you have an Apple phone . You’ll have to log into your Apple ID

if you want to exclude a portion of an image which option should be chosen?? A. Arrange B. Position C. Crop D. Delete

Answers

It would be C- crop. This allows you to specifically delete parts of the image using drag and drop features. Hope this helps!
Other Questions
help! Im not sure if its c or d thanks!! Which of these is an organism? PLEASE ASAP FOR BRAINLIEST Ship Co. produces storage crates that require 34.0 meters of material at $0.20 per meter and 0.30 direct labor hours at $19.00 per hour. Overhead is applied at the rate of $16 per direct labor hour. What is the total standard cost for one unit of product that would appear on a standard cost card? The number of yeast cells in a laboratory culture increases rapidly initially but levels off eventually. The population is modeled by the function n = f(t) = a 1 + be0.7t where t is measured in hours. At time t = 0 the population is 30 cells and is increasing at a rate of 18 cells/hour. Find the values of a and b. Te parece que se podra representar en una dramatizacion las acciones que se presentan en el texto "las obras de cocinero"? Which sentence best illustrates an appeal to ethos?A. How might future generations judge us if we fail to improve ourcity when we had the chance to do so?B. Think of the children who have to grow up in a concrete jungle,barren of soft grass and shady trees.C. A public park brings more foot traffic to the city center, increasingopportunities for local businesses to prosper.D. Living in the city for 10 years has shown me that public greenspaces are important.SUBMIT Increased Efficiency, Inc. is looking for ways to shorten its cash conversion cycle. It has annual sales of $36,500,000, or $100,000 a day on a 365-day basis. The firm's cost of goods sold is 65% of sales. On average, the company has $9,000,000 in inventory and $8,000,000 in accounts receivable. Its CFO has proposed new policies that would result in a 20% reduction in both average inventories and accounts receivable. She also anticipates that these policies would reduce sales by 10%, while the payables deferral period would remain unchanged at 40 days. What effect would these policies have on the company's cash conversion cycle Read the sentence.The movie is an invented story about the jazz scene, but it is interspersed with archival footage and photographs offamous poets and singers of the time.In this context what is the meaning of 'interspersed"?A. combinedB. comparedC. offeredD. shared U 3 4Lucy buys 7 kg of nuts to sell.She pays 10 for the nuts.Lucy puts all the nuts into bags.She puts 350 g of nuts into each bag.She then sells each bag of nuts for 75p.Lucy sells all the bags of nuts.Work out her percentage profit. Need help with these problems .( Its okay if u dont know all .Just do what you know) In 2019, Willow Corporation had three employees. Two of the employees worked full-time and earned salaries of $25,000 each. The third employee worked only part-time and earned $4,000. The employer timely paid state unemployment tax equal to 5.4 percent of each employee's wages up to $7,000. How much FUTA tax is due from Willow Corporation for 2019, after the credit for state unemployment taxes Biochemical changes in the body, that affect the rate of metabolism and elimination of a substance from the body and produce increased amounts to achieve the desired effects, may lead to development of The first two terms in a sequence are 8 and 11. What is the next value if this sequence is arithmetic? Plz HELP!!!!!!!!!!!!!!!!!!!!! What is your book genre?(If you read) When something is parallel to each other there what A certain mass of carbon reacts with 9.53 g of oxygen to form carbon monoxide. ________ grams of oxygen would react with that same mass of carbon to form carbon dioxide, according to the law of multiple proportions. Ethene is a useful substance that can form polymers. It has a melting point of 169C and a boiling point of 104C. At which temperature would ethene be a liquid? A 300 g bird flying along at 6.2 m/s sees a 10 g insect heading straight toward it with a speed of 35 m/s (as measured by an observer on the ground, not by the bird). The bird opens its mouth wide and enjoys a nice lunch.Required:What is the bird's speed immediately after swallowing?