Question

IndexPage - a subclass of Page, stores at most 20 terms and associated page numbers on separate lines. The term is placed at the beginning of the line, and the page numbers are placed (comma-separated) at the end of the line, with dots placed in between them as padding to ensure right-aligned page numbers. The IndexPage subclass has data which is collected from a given Chapter. The Pages of a Chapter should be iterated through to find the top 20 index terms per Chapter. Create an ArrayList of IndexEntry objects, and each time a new word is found on a Page, add an entry. When a word with an existing entry is found, increase the counter for that entry and add the current page number to the list. To check if an ArrayList already contains a potential new entry for a given word (e.g. list.contains(aNewEntry)), the method boolean equals(Object) must be implemented in IndexEntry. After casting the actual parameter to an IndexEntry, return whether the field index term is equal to the passed object's index term. Finding the top 20 entries may be done in several ways. One option is to find the entry with the largest count, add it to another ArrayList, search the entry list for decreasing counts, and add each until the new list has 20 entries. The other option is to sort an ArrayList of IndexEntry objects by the count field. This requires the interface Comparable to be implemented, and compareTo will return the difference of IndexEntry counts. See the slides on Chapter 13: Abstract Classes and Interfaces, page 20 for more information. Each term is listed on a separate line with the list of page numbers where that term occurred. Terms may appear in any order.

          IndexPage - a subclass of Page, stores at most 20 terms and associated page numbers on separate lines. The term is placed at the beginning of the line, and the page numbers are placed (comma-separated) at the end of the line, with dots placed in between them as padding to ensure right-aligned page numbers.

The IndexPage subclass has data which is collected from a given Chapter. The Pages of a Chapter should be iterated through to find the top 20 index terms per Chapter. Create an ArrayList of IndexEntry objects, and each time a new word is found on a Page, add an entry. When a word with an existing entry is found, increase the counter for that entry and add the current page number to the list.

To check if an ArrayList already contains a potential new entry for a given word (e.g. list.contains(aNewEntry)), the method boolean equals(Object) must be implemented in IndexEntry. After casting the actual parameter to an IndexEntry, return whether the field index term is equal to the passed object's index term.

Finding the top 20 entries may be done in several ways. One option is to find the entry with the largest count, add it to another ArrayList, search the entry list for decreasing counts, and add each until the new list has 20 entries. The other option is to sort an ArrayList of IndexEntry objects by the count field. This requires the interface Comparable to be implemented, and compareTo will return the difference of IndexEntry counts. See the slides on Chapter 13: Abstract Classes and Interfaces, page 20 for more information.

Each term is listed on a separate line with the list of page numbers where that term occurred. Terms may appear in any order.
        
Show more…

Added by Juan V.

Computer Science and Information Technology
Computer Science and Information Technology
Trishna Knowledge Systems 2018 Edition
AceChat toggle button
Close icon
Ace pointing down

Please give Ace some feedback

Your feedback will help us improve your experience

Thumb up icon Thumb down icon
Thanks for your feedback!
Profile picture
IndexPage - a subclass of Page, stores at most 20 terms and associated page numbers on separate lines. The term is placed at the beginning of the line, and the page numbers are placed (comma-separated) at the end of the line, with dots placed in between them as padding to ensure right-aligned page numbers. The IndexPage subclass has data which is collected from a given Chapter. The Pages of a Chapter should be iterated through to find the top 20 index terms per Chapter. Create an ArrayList of IndexEntry objects, and each time a new word is found on a Page, add an entry. When a word with an existing entry is found, increase the counter for that entry and add the current page number to the list. To check if an ArrayList already contains a potential new entry for a given word (e.g. list.contains(aNewEntry)), the method boolean equals(Object) must be implemented in IndexEntry. After casting the actual parameter to an IndexEntry, return whether the field index term is equal to the passed object's index term. Finding the top 20 entries may be done in several ways. One option is to find the entry with the largest count, add it to another ArrayList, search the entry list for decreasing counts, and add each until the new list has 20 entries. The other option is to sort an ArrayList of IndexEntry objects by the count field. This requires the interface Comparable to be implemented, and compareTo will return the difference of IndexEntry counts. See the slides on Chapter 13: Abstract Classes and Interfaces, page 20 for more information. Each term is listed on a separate line with the list of page numbers where that term occurred. Terms may appear in any order.
Close icon
Play audio
Feedback
Powered by NumerAI
David Collins Jennifer Stoner
Ivan Kochetkov verified

Supreeta N and 88 other subject AP CS educators are ready to help you.

Ask a new question

*

Labs

-

Want to see this concept in action?

NEW

Explore this concept interactively to see how it behaves as you change inputs.

View Labs

*

Key Concepts

-
Key Concept
Premium Feature
Explore the core concept behind this problem.
Play button
Key Concept
Premium Feature
Explore the core concept behind this problem.
Your browser does not support the video tag.

*

Recommended Videos

-
import-javautilscanner-word-manager-52pp-collection-of-strings-author-your-name-here-public-class-wordmanager-adds-the-word-to-the-next-empty-space-in-the-array-if-there-is-space-returns-the-24779

import java.util.Scanner; /** * Word Manager (5.2PP Collection of Strings) * * @author Your Name Here */ public class WordManager { /** * Adds the word to the next empty space in the array, if there is space. * Returns the new size of the array. */ public static int add(String[] words, int count, String word) { //TO DO: Complete the implementation of this method return count; } /** Displays the words in the collection as a comma separated list. */ public static void printList(String[] words, int count) { //TO DO: Complete the implementation of this method } //TO DO: Add an implementation of averageLength public static void main(String[] args ) { Scanner sc = new Scanner(System.in); //TO DO: Add necessary variable (and constant) declarations and initialisations //TO DO: Implement the menu } } Program: WordManager Constants: int CAPACITY, maximum number of words, initialized to 20 Variables: Scanner sc, to read user input, initialized when declared String[] words, collection of words, initialized to hold CAPACITY elements int count, number of elements in words, initialized to 0 int choice, user's menu selection String aWord, new word given by user Steps: 1. Display "Word Manager" 2. Do 3. Display a menu "1. Add a word 2. Display words 3. Display average word length 4. Quit" 4. Prompt user to "Enter option: " 5. Assign choice value of next int from sc (the Scanner) 6. Switch based on choice 7. In the case that choice is 1: - Prompt for and read in next word from user, storing in aWord - Assign count result of calling add with words, count, aWord 8. In the case that choice is 2: - Call printList with words, count 9. In the case that choice is 3: - Display "Average word length: " + result of calling averageLength with words, count 10. While choice is not 4 Method: double averageLength(String[] words, int count) Returns: double, the average length of the first count words in the array words Parameters: String[] words, the list of words int count, the number of filled positions in the array Variables: For you to decide Steps: 1. Calculate the sum of each word's length 2. Calculate and return the average word length (that sum divided by count)

Supreeta N.

develop-the-java-program-for-the-following-applicationapplicants-to-a-master-program-need-to-be-sorted-according-to-some-attributes-of-applicantsthe-attributes-are-ales-score-undergraduate-g-98003

Develop the Java program for the following application. Applicants to a master program need to be sorted according to some attributes of applicants. The attributes are ALES score, undergraduate GPA, master exam score, and interview scores from two jury members. These attributes of an applicant are processed as explained below, and a weighted average of these scores is calculated, which makes the final score of the applicant. Applicants are sorted according to their final score in descending order. The sorted list is displayed. The final score is computed as follows: ALES scores are between 0 and 100. Undergraduate GPAs are between 0 and 4. Since the minimum graduate point is 2.00, in order to compare all scores, they have to be on the same scale. 4.0 is mapped to 100, and 2.00 is mapped to 50. For example, if the GPA is 3.00 over 4, it is mapped to 75. The exam score is between 0 and 100. Interview points are between 0 and 10 for each jury member. Then the interview score is the average of the two jury points. Map the overall interview score between 0 and 100 as for CPA. After preprocessing all four scores and bringing them to the 0-100 interval, a weighted average is calculated. Define weights properly; not applicant-specific but general characteristics of the Applicant class. For this year, weights are as follows: ALES 0.35, GPA: 0.2, exam: 0.3, and interview 0.15. Write the program for general weights adding to 1.0. Classes in the program: Person: defines the name, last name of the applicant. Applicant: defines applicant ID as a new attribute specific to an applicant. Methods: compareTo method: concrete implementation of the compareTo method in the generic comparable interface. Compares two applicants according to the final score. toString method: prepares a string representation of the applicant benefit from Person's toString method. Define other variables or methods properly. Test class: Generic sort method with ascending and descending order options defined as a boolean parameter, able to sort any type of objects via the implementation of the compareTo methods. Print method: printing any object via toString method. In the main method, applicants are generated and stored in an array. Send the array to the sort method and display the sorted list to the screen. Do not get any information from the screen.

Akash M.

part-1-pseudo-code-design-and-write-the-psuedo-code-for-the-following-problem-statement-problem-statement-creates-a-functioninputnumbersthat-uses-a-loop-to-allow-the-user-to-input-5-numbers-95209

Part 1 - Pseudo-code Design and write the pseudo-code for the following problem statement. Problem Statement: Create a function called inputNumbers that uses a loop to allow the user to input 5 numbers between 1 and 10 and store them in an array called numArray. All input should be validated as a number between 1-10 inclusive. Call the function from the main() function. Create a function called addNums that accepts numArray and uses a loop to add the numbers in the array. Call the function from the main() function. Return the total to the main() function and assign the total to a variable called total. Display the value of total. Create a function called writeArray that writes the contents of the array to a file called "dat", with one number per line. If a file called "Exam2.dat" already exists, create a new file. Call the function from the main() function. Create a function called readArray that reads the contents of the file and displays them. Display how many of the numbers read are greater than 5 and how many of the numbers are 5 or less. Implement the following pseudo-code for the main module exactly as shown: Main module: // Call the function to input numbers. Set numArray = inputNumbers() // Call the function to add numbers. Set total = addNums(numArray) Display "The total of the numbers is", total // Write the array contents to a file. Call writeArray(numArray) // Read and display the numbers in the file. Call readArray() End Module Expected Input/Output: Please enter 5 numbers between 1 and 10: 5 7 8 2 3 The total of the numbers is 25. Writing numbers to a file... Reading numbers from a file... The numbers are: 5 7 8 2 3 2 of the numbers are greater than 5. 3 of the numbers are 5 or less. Part 2 - Programming Code Take the pseudo-code you designed and write the Java program code in a Word document. Submit the pseudo-code and programming code in one Word document. Use the headings provided to indicate Part 1 and Part 2 for this question.

Akash M.


*

Recommended Textbooks

-
Computer Science and Information Technology

Computer Science and Information Technology

Trishna Knowledge Systems 2018 Edition
achievement 1,492 solutions
Introduction to Programming Using Python

Introduction to Programming Using Python

Y. Daniel Liang 1st Edition
achievement 1,133 solutions
Computer Science - An Overview

Computer Science - An Overview

Glenn Brookshear, Dennis Brylow 12th Edition
achievement 1,732 solutions

*

Transcript

-
00:01 Hello students, here is the java program called as the word manager that manages the collection of this string.
00:07 So, wait, first of all we will import the required libraries.
00:10 The code starts by importing the java .util .scanner which is used to take the user input and the constants as well as the class are declared.
00:20 So it declares a class named as the word manager and defines the constants capacity with a value of 20 representing the maximum number of the words that can be stored.
00:31 And then it adds the method whereas the add method is declared with the three parameters word, count as well as the words.
00:44 So the words and an array of the string where the words will be added in a count, an integer representing the current count of the word in an array and the only word, the word is the new word to be added.
01:00 So this method is the placeholder with the comment as todo.
01:05 It is with a todo over here indicating that implementing is not provided in the code.
01:11 So in a print list, in a print list method, so whereas the method is declared with the two parameters words and the count.
01:20 So words as the array of the string containing the words and the count as an integer representing the current count of the words in the array.
01:30 The average, as you can see the average length method, this method is declared with the two parameters as the same words and the count.
01:40 And in this method another placeholder with the comment indicating that its implement is not provided over in the code.
01:46 In a main method, so in a main method, in a main method, the main method is the entry point of the program.
01:58 It creates the scanner object called named as an sc with an sc.
02:03 So to read the user input and initializes an array of the string named as words with the capacity defined by the capacity constant.
02:12 Initializes a string, an integer variable count to keep the track of the number of the words in an array.
02:18 Then initializes the integer choice to store the user menu choice selection...
Need help? Use Ace
Ace is your personal tutor. It breaks down any question with clear steps so you can learn.
Start Using Ace
Ace is your personal tutor for learning
Step-by-step explanations
Instant summaries
Summarize YouTube videos
Understand textbook images or PDFs
Study tools like quizzes and flashcards
Listen to your notes as a podcast
Continue solving this problem
Create a free account to:
  • View full step-by-step solution
  • Ask follow-up questions with Ace AI
  • Save progress and study later
Continue Free
Join the community

18,000,000+

Students on Numerade


Trusted by students at 8,000+ universities

Numerade

Get step-by-step video solution
from top educators

Continue with Clever
or



By creating an account, you agree to the Terms of Service and Privacy Policy
Already have an account? Log In

A free answer
just for you

Watch the video solution with this free unlock.

Numerade

Log in to watch this video
...and 100,000,000 more!


EMAIL

PASSWORD

OR
Continue with Clever