Got Homework?
Connect with other students for help. It's a free community.
Here's the question you clicked on:
 0 viewing
scherniak
Group Title
how can I write a program that gets a set of n integers from the user and tells them the frequency of each number. Ex: Input: 3. 7. 2. 5. 8. 1. 3. 5. 5. 8
Output:
1 1
2 1
3 2
5 3
7 1
8 2
mainly having problems with the searching aspect
 2 years ago
 2 years ago
scherniak Group Title
how can I write a program that gets a set of n integers from the user and tells them the frequency of each number. Ex: Input: 3. 7. 2. 5. 8. 1. 3. 5. 5. 8 Output: 1 1 2 1 3 2 5 3 7 1 8 2 mainly having problems with the searching aspect
 2 years ago
 2 years ago

This Question is Closed

ShadowZzz Group TitleBest ResponseYou've already chosen the best response.0
In what computer language?
 2 years ago

Vibhor16 Group TitleBest ResponseYou've already chosen the best response.0
array of n numbers one entry for each number add one to the entry as the user inputs the number display entry name and number it holds
 2 years ago

Vibhor16 Group TitleBest ResponseYou've already chosen the best response.0
@ShadowZzz You can write your answer in pseudo code.
 2 years ago

keketsu Group TitleBest ResponseYou've already chosen the best response.1
Definitely many ways to do this. A few come to mind. I'll use Python as the example language. 1. Append each entry to the list then run a list.count() command on each entry. (Of course you'd have to account for the multiple entries, maybe by sorting the list and only printing if the current entry is not the same as the one before it.) 2. Create a dictionary. If the entry does not exist in the dictionary, add it with the value of 0. If the entry does exist, increase the associated value by 1. 3. Variables. You could sort your list, and then create a "num_frequency" variable. Increment your variable by 1 when your list entries are duplicates. Display the variable and reset it when they aren't. Of course, not all approaches are equal. But this at least shows a number of ways to approach the problem.
 2 years ago

scherniak Group TitleBest ResponseYou've already chosen the best response.2
I'm working in Java. I was thinking of using a nested for loop but i cant really figure out exactly what to do
 2 years ago
See more questions >>>
Your question is ready. Sign up for free to start getting answers.
spraguer
(Moderator)
5
→ View Detailed Profile
is replying to Can someone tell me what button the professor is hitting...
23
 Teamwork 19 Teammate
 Problem Solving 19 Hero
 Engagement 19 Mad Hatter
 You have blocked this person.
 ✔ You're a fan Checking fan status...
Thanks for being so helpful in mathematics. If you are getting quality help, make sure you spread the word about OpenStudy.