6. Write a program that reads numbers from the keyboard into an array of type int[]. You may assume that there will be 50 or fewer entries in the arraY. Your program allows any number of numbers to be entered, up to 50. The output is to be a two-column list. The first column is a list of the distinct array elements; the second column is the count of the number of occurrences of each element. The list should be sorted on entries in the first column, largest to smallest. For the array -12 3 -12 4 11-12 1-1 123 42 3 -12 the output should be [Check Sample Run] SAMPLE RUN #4: java Distinct Interactive Session Hide Invisibles Enter number -of-elements:16e Enter next-element:-12- Enter next.element:3 Enter next.element:-12- Enter next.element:4- Enter-next.element:1- Enter next element:1- Enter next-element:-124 Enter next-element:14 Enter next-element:-1e Enter next.element:1- Enter next.element:2- Enter next element:3 Enter-next element:4- Enter next element:2- Enter.next-element:34 Enter next-element:-12- N-Counte 4+2- 3+34 2-2+ 1+4+ -1+14 -12+4+

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question
6. Write a program that reads numbers from the keyboard into an array of type
int[]. You may assume that there will be 50 or fewer entries in the array. Your
program allows any number of numbers to be entered, up to 50, The output is to
be a two-column list. The first column is a list of the distinct array elements; the
second column is the count of the number of occurrences of each element. The list
should be sorted on entries in the first column, largest to smallest.
For the array
-12 3 -12 4 11 -12 1-1 123 4 2 3 -12
the output should be
[Check Sample Run]
SAMPLE RUN #4: java Distinct
Interactive Session
Hide Invisibles
Enter number of.elements:16-
Enter.next element:-124
Enter next.element:34
Enter next.element:-12
Enter nextelement:4
Enter next element:14
Enter next.element:14
Enter next·element:-124
Enter next element:14
Enter next element:-1e
Enter next.element:1-
Enter next.element:24
Enter next.element:3
Enter nextelement:4-
Enter nextelement:24
Enter nextelement:3
Enter next.element: -124
N+Counte
4+24
334
2-24
1+44
-1+14
-12+4+
Transcribed Image Text:6. Write a program that reads numbers from the keyboard into an array of type int[]. You may assume that there will be 50 or fewer entries in the array. Your program allows any number of numbers to be entered, up to 50, The output is to be a two-column list. The first column is a list of the distinct array elements; the second column is the count of the number of occurrences of each element. The list should be sorted on entries in the first column, largest to smallest. For the array -12 3 -12 4 11 -12 1-1 123 4 2 3 -12 the output should be [Check Sample Run] SAMPLE RUN #4: java Distinct Interactive Session Hide Invisibles Enter number of.elements:16- Enter.next element:-124 Enter next.element:34 Enter next.element:-12 Enter nextelement:4 Enter next element:14 Enter next.element:14 Enter next·element:-124 Enter next element:14 Enter next element:-1e Enter next.element:1- Enter next.element:24 Enter next.element:3 Enter nextelement:4- Enter nextelement:24 Enter nextelement:3 Enter next.element: -124 N+Counte 4+24 334 2-24 1+44 -1+14 -12+4+
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps with 3 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY