1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
LUCKY_DIMON [66]
4 years ago
13

Write a program that prompts the user to enter integers in the range 1 to 50 and counts the occurrences of each integer. The pro

gram 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:
Computers and Technology
1 answer:
galben [10]4 years ago
8 0

Answer:

  1. import java.util.Scanner;
  2. public class Main {
  3.    public static void main(String[] args) {
  4.        int num[] = new int[51];
  5.        Scanner input = new Scanner(System.in);
  6.        System.out.print("Number of input: ");
  7.        int limit = input.nextInt();
  8.        for(int i=0; i < limit; i++){
  9.            System.out.print("Input a number (1-50): ");
  10.            int k = input.nextInt();
  11.            num[k]++;
  12.        }
  13.        for(int j=1; j < 51; j++){
  14.            if(num[j] > 0){
  15.                System.out.println("Number of occurrence of " + j + ": " + num[j]);
  16.            }
  17.        }
  18.    }
  19. }

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).

You might be interested in
Linguist study_____
-Dominant- [34]
That's B.

Linguist love all kinds of studies of languages culture writing etc.
6 0
3 years ago
.حدد/ي الكيانات في النظام
olasank [31]

Answer:

what

Explanation:

6 0
3 years ago
Read 2 more answers
How do i get around a school related block
dimulka [17.4K]

Answer:

try putting "uk-" or "us-" depending on where you are, you could also go through your settings and try to allow everything.

3 0
3 years ago
Read 2 more answers
Between which zones and a DMZ should firewalls be placed? Choose two answers.
brilliants [131]

Answer:

Internal and External Zones

Explanation:

Demilitarized Zone (DMZ) in a network means that, we make sure the security of network at higher level as military make sure the security of their bases or zones.

In this type of network, The network of the internal organization (LAN) needs security from hackers and unauthorized users who are trying to access the resources and information from the network.

This network is divided into two major zones. A DMZ has been placed between two zones along with firewalls enhance the security of LAN Network from the networks on internet. These two zones are named as Internal and External Zone. The firewall between DMZ and External zones monitors the users from external networks on the internet who tries to access organization's network. Internal network monitors the traffic between DMZ and Internal LAN network.

4 0
4 years ago
How to check if your computer has bluetooth?
Lelu [443]
Assuming you're running Windows, click the start button, and then search for "Device Manager" (or open CMD or PowerShell and type devmgmt.msc). Look at the list of devices. If Bluetooth is there, you have it; if it's not there, you don't. 
5 0
3 years ago
Other questions:
  • Can anybody answer this for me
    13·2 answers
  • What's the ASCII code for boy ?
    15·1 answer
  • Side mirror using convex mirror or concave mirror?​
    5·2 answers
  • To read visual and audio text means
    11·1 answer
  • Going to Grad School! In the College of Computing and Software Engineering, we have an option for students to "FastTrack" their
    11·1 answer
  • Contrast the following terms (provide examples): Partial dependency; transitive dependency
    14·1 answer
  • The game often becomes stuck on landscape mode when tilting the device during gameplay, which cuts off some peripheral text. A w
    8·1 answer
  • Dynamic programming does not work if the subproblems: ___________
    5·1 answer
  • Which of these describes a database? Check all of the boxes that apply.
    15·1 answer
  • Responsible use of computer is known as ................. .​
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!