Introduction to Java Programming and Data Structures, Comprehensive Version (11th Edition)
11th Edition
ISBN: 9780134670942
Author: Y. Daniel Liang
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Concept explainers
Question
Chapter 21, Problem 21.6PE
Program Plan Intro
MaximumOccurence.Java
Program Plan:
- Include the class name named “Count_Occurence”.
- Declare the package.
- Import the util package.
- Define class.
- Declare the main()method.
- Create a Scanner.
- Create a list and two sets.
- Prompt the user to enter number of integers.
- Declare an integer variable “key”.
- Continue loop till entered value is 0.
- Assign value to key as 1 if map does not contain key.
- Calculate and assign frequency to key.
- Find the maximum occurrence.
- Display the integers that have the most occurrences.
- Enter into the map and print the key with the maximum occurrence.
- Close the main method.
- Close the class.
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
(IN C LANGUAGE) Cumulative Addition: Computer selects a number between 7 and 23 at random. User will only add 2, 3 or 5 numbers to reach that number.For example: To reach 14:
User will enter 5 5 2 2 (4 input).Also he can enter 2 2 2 2 2 2 2 (7 input) or 3 3 3 3 2 (5 input).
https://www.bartleby.com/questions-and-answers/in-c-language-cumulative-addition-computer-selects-a-number-between-7-and-23-at-random.-user-will-on/0509c740-d993-44ed-a468-7e02da552600
Q5. (Find the second lowest interger number) Write a program that prompts the user to enter
a set of integer numbers, and finally displays the second lowest integer number in the set. To
exit from the program enter -1.
Here is a sample run
Enter a set of integer numbers: 3 57
928-1 The second lowest number is
3.
[Calculate grades’ average for a student] write a program that calculates the student grades’ average for a semester for the number of courses taken in that semester. Your program should do the following:
1.Read from user the number of courses (n)
2. Then, read the courses’ grades for n times (Hint: use a loop)
3.If a grade is grater than 100 or less than 0, ask the user to enter the grade again.
4.Calculate the average of grades using the following formula:
average = (sum of grades) / n
5.Print out the average grade on the screen.
Note: Always use appropriate data types.
Chapter 21 Solutions
Introduction to Java Programming and Data Structures, Comprehensive Version (11th Edition)
Ch. 21.2 - Prob. 21.2.1CPCh. 21.2 - Prob. 21.2.2CPCh. 21.2 - Prob. 21.2.3CPCh. 21.2 - Prob. 21.2.4CPCh. 21.2 - Prob. 21.2.5CPCh. 21.2 - Suppose set1 is a set that contains the strings...Ch. 21.2 - Prob. 21.2.7CPCh. 21.2 - Prob. 21.2.8CPCh. 21.2 - What will the output be if lines 67 in Listing...Ch. 21.2 - Prob. 21.2.10CP
Ch. 21.3 - Prob. 21.3.1CPCh. 21.3 - Suppose you need to write a program that stores...Ch. 21.3 - Suppose you need to write a program that stores...Ch. 21.3 - Suppose you need to write a program that stores a...Ch. 21.3 - Prob. 21.3.5CPCh. 21.3 - Prob. 21.3.6CPCh. 21.4 - Prob. 21.4.1CPCh. 21.4 - Prob. 21.4.2CPCh. 21.5 - Prob. 21.5.1CPCh. 21.5 - Prob. 21.5.2CPCh. 21.5 - Prob. 21.5.3CPCh. 21.6 - Prob. 21.6.1CPCh. 21.6 - Prob. 21.6.2CPCh. 21.6 - Prob. 21.6.3CPCh. 21.6 - Prob. 21.6.4CPCh. 21.7 - Prob. 21.7.1CPCh. 21.7 - Prob. 21.7.2CPCh. 21 - Prob. 21.1PECh. 21 - (Display nonduplicate words in ascending order)...Ch. 21 - Prob. 21.3PECh. 21 - (Count consonants and vowels) Write a program that...Ch. 21 - Prob. 21.6PECh. 21 - (Revise Listing 21.9, CountOccurrenceOfWords.java)...Ch. 21 - Prob. 21.8PECh. 21 - Prob. 21.9PE
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Similar questions
- C++ ONLYTomorrow is the closing ceremony for the 2022 World Cup, and Cody and his friends want to know who the top scorer of the tournament is. John and the others insist that it Lionel Messi who is the top-scorer (scoring 10) but Cody, a Ronaldo fan, is stubborn and decided to make a list of all the players who scored goals and order them randomly. He then must look for the highest number and see if that number is higher than Messi’s goals. Input the number of players then input the number of goals scored for each. Print "Not Messi" if the highest goals exceed 10 and "Okay, fine, it's Messi" if it doesn’t.Enter·the·number·of·players:·4 Goals·score·by·player·#1:·7 Goals·score·by·player·#2:·2 Goals·score·by·player·#3:·5 Goals·score·by·player·#4:·1 Okay,·fine,·it's·Messiarrow_forward5: CheckLetter.cpp) Write a program that adds a checkletter to an eight-digit number. The check letter should becomputed as follows: Break the number up into 4 two-digitnumbers. Add the four numbers together. Find theremainder after division by 26. The check letter is the letterin the alphabet that corresponds to the number justcomputed. (A=0, B=1, C=2, etc.) Print the original numberfollowed by the check letter. Use at least one ffunction thatreturns a value when you write this program.arrow_forward. Modify that program so that any number of responses can be entered, and the user does not have to count the number of responses in the list. Set up the program so that the value 999 can be keyed in by the user to indicate that the last response has been entered, not including 999. ( Hint: You can use the break statement here if you want to exit your looarrow_forward
- (IN C LANGUAGE) Cumulative Addition: Computer selects a number between 7 and 23 at random. User will only add 2, 3 or 5 numbers to reach that number. For example: To reach 14:User will enter 5 5 2 2 (4 input).Also he can enter 2 2 2 2 2 2 2 (7 input) or 3 3 3 3 2 (5 input)arrow_forwardAlert dont submit AI generated answer.arrow_forward(Financial: credit card number validation) Credit card numbers follow certain pat- terns. A credit card number must have between 13 and 16 digits. It must start with: 4 for Visa cards 5 for Master cards 37 for American Express cards 6 for Discover cards In 1954, Hans Luhn of IBM proposed an algorithm for validating credit card numbers. The algorithm is useful to determine whether a card number is entered correctly or whether a credit card is scanned correctly by a scanner. Credit card numbers are generated following this validity check, commonly known as the Luhn check or the Mod 10 check, which can be described as follows (for illustra- tion, consider the card number 4388576018402626): 1. Double every second digit from right to left. If doubling of a digit results in a two-digit number, add up the two digits to get a single-digit number. 4388576018402626 → 2 * 2 = 4 → 2 * 2 = 4 → 4 * 2 = 8 → 1 * 2 = 2 6 * 2 = 12 (1+ 2 = 3) → 5 * 2 = 10 (1+ 0 = 1) → 8 * 2 = 16 (1 + 6 = 7) → 4 * 2 = 8arrow_forward
- (Bar-Chart Printing Program) One interesting application of computers is drawing graphsand bar charts. Write a program that reads five numbers (each between 1 and 30). For each numberread, your program should print a line containing that number of adjacent asterisks. For example,if your program reads the number seven, it should print *******.arrow_forward(Sort three numbers) Write the following function to display three numbers in increasing order: def displaySortedNumbers(num1, num2, num3): Write a test program that prompts the user to enter three numbers and invokes the function to display them in increasing order. Here are some sample runs:arrow_forward(Same-number subsequence) JAVA Class Name: Exercise22_05 Write an O(n) program that prompts the user to enter a sequence of integers ending with 0 and finds the longest subsequence with the same number. Sample Run 1 Enter a series of numbers ending with 0:2 4 4 8 8 8 8 2 4 4 0The longest same number sequence starts at index 3 with 4 values of 8 Sample Run 2 Enter a series of numbers ending with 0: 34 4 5 4 3 5 5 3 2 0 The longest same number sequence starts at index 5 with 2 values of 5arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- C++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology PtrC++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage Learning
C++ for Engineers and Scientists
Computer Science
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Course Technology Ptr
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning