Java: An Introduction to Problem Solving and Programming (8th Edition)
Java: An Introduction to Problem Solving and Programming (8th Edition)
8th Edition
ISBN: 9780134462035
Author: Walter Savitch
Publisher: PEARSON
Question
Book Icon
Chapter 12, Problem 10PP
Program Plan Intro

“GroupHolder” class

Program Plan:

  • Import required package.
  • Define “Main” class.
    • Define “GroupHolder” class
      • Create an array list “items” from “GroupHolder” class.
    • Method definition for “findGroupNodeFor”
      • Declare variable using “GroupNode” type.
      • Set node “n” to “null”.
      • Set “found” to “false”.
      • Check condition using “while” loop
        • Compute next node.
        • If “n” equal to “s”, then set “found” to “true”.
          • If found, then returns the value of “n”.
          • Otherwise, returns null.
    • Method definition of “addItem”.
      • Call “findGroupNodeFor” method and store it to a variable “n”.
      • If “n” is null, then add it to “items”.
    • Method definition for “getRepresentative”.
      • Call “findGroupNodeFor” method and store it to a variable “n”.
      • Check condition using “while” loop.
        • Set node to link value at node
          • Finally returns the data at node.
    • Method definition of “getAllRepresentatives”.
      • Create an array list.
      • Add data to “items”.
      • Finally returns the result.
    • Method definition of “inSameGroup”.
      • Assign representative for string “s1” and store result to “r1”.
      • Assign representative for string “s2” and store result to “r2”.
      • Returns result.
    • Method definition of “union”
      • Assign representative for string “s1” and store result to “r1”.
      • Assign representative for string “s2” and store result to “r2”.
      • Check condition.
        • Find group node for “r1” and “r2”.
    • Create “GroupNode” class.
      • Declare required variables.
      • Create constructor for “GroupNode” class.
      • Create parameterized for “GroupNode” class.
    • Define main function.
      • Create object “g” from “GroupHolder” class.
      • Add item to “g” by calling the method “addItem”.
      • Display groups by calling the method “getAllRepresentatives”.
      • Join groups by calling the method “union”.
      • Display groups after performing unions operations.
      • Check “a” and “e” is in same group by calling method “inSameGroup”.
      • Check “a” and “f” is in same group by calling method “inSameGroup”.

Blurred answer
Students have asked these similar questions
Q/ Write a program in C# that lets the user to define the number of rows and columns. Then, the program reads the matrix and finds the index of the even and odd numbers and display them with their corresponding indices. Use adequate messages during the program execution.
For any element in keysList with a value greater than 100, print the corresponding value in itemsList, followed by a space. Ex: If keysList = {42, 105, 101, 100} and itemsList = {10, 20, 30, 40}, print: 20 30 Since keysList.at(1) and keysList.at(2) have values greater than 100, the value of itemsList.at(1) and itemsList.at(2) are printed. #include <iostream>#include <vector>using namespace std; int main() {const int SIZE_LIST = 4;vector<int> keysList(SIZE_LIST);vector<int> itemsList(SIZE_LIST);unsigned int i; for (i = 0; i < keysList.size(); ++i) {cin >> keysList.at(i);} for (i = 0; i < itemsList.size(); ++i) {cin >> itemsList.at(i);} /* Your solution goes here */ cout << endl; return 0;} Please help me with this problem using c++.
Please solve this question in JAVA| Write a Java program that asks the user to enter items until the user chooses to stop, stores them into links (nodes), and chains the links together into a linked list. You will need to make the following changes: • Your linked list should store information about Customers' Transactions that contain three fields: customer name (string), customer number (int), and transaction description (string). • Instead of putting all of your code inside the main source code file, you should create the following functions: 1. addToStart(Item x) 2. addToEnd(Item x) 3. insertAt(Item x, int n) 4. remove(int customer_number) 5. reverse) 6. printList) Instead of simply asking the user if they want to add a new link, your main program should offer the user a menu of options: 1. Add a new link to the end 2. Add a new link to the beginning 3. Insert an element at index n into the list. 4. Remove a link from the list 5. Reverse the list 6. Print out the entire list 7. Quit…

Chapter 12 Solutions

Java: An Introduction to Problem Solving and Programming (8th Edition)

Ch. 12.1 - Prob. 12STQCh. 12.2 - Prob. 13STQCh. 12.2 - Prob. 14STQCh. 12.2 - Prob. 15STQCh. 12.2 - Prob. 16STQCh. 12.3 - Prob. 17STQCh. 12.3 - Prob. 18STQCh. 12.3 - Prob. 19STQCh. 12.3 - Write a definition of a method isEmpty for the...Ch. 12.3 - Prob. 21STQCh. 12.3 - Prob. 22STQCh. 12.3 - Prob. 23STQCh. 12.3 - Prob. 24STQCh. 12.3 - Redefine the method getDataAtCurrent in...Ch. 12.3 - Repeat Question 25 for the method...Ch. 12.3 - Repeat Question 25 for the method...Ch. 12.3 - Repeat Question 25 for the method...Ch. 12.4 - Revise the definition of the class ListNode in...Ch. 12.4 - Prob. 30STQCh. 12.5 - What is the purpose of the FXML file?Ch. 12.5 - Prob. 32STQCh. 12 - Repeat Exercise 2 in Chapter 7, but use an...Ch. 12 - Prob. 2ECh. 12 - Prob. 3ECh. 12 - Repeat Exercises 6 and 7 in Chapter 7, but use an...Ch. 12 - Write a static method removeDuplicates...Ch. 12 - Write a static method...Ch. 12 - Write a program that will read sentences from a...Ch. 12 - Repeat Exercise 12 in Chapter 7, but use an...Ch. 12 - Write a program that will read a text file that...Ch. 12 - Revise the class StringLinkedList in Listing 12.5...Ch. 12 - Prob. 12ECh. 12 - Write some code that will use an iterator to...Ch. 12 - Prob. 14ECh. 12 - Write some code that will use an iterator to...Ch. 12 - Prob. 17ECh. 12 - Revise the method selectionSort within the class...Ch. 12 - Repeat the previous practice program, but instead...Ch. 12 - Repeat Practice Program 1, but instead write a...Ch. 12 - Write a program that allows the user to enter an...Ch. 12 - Write a program that uses a HashMap to compute a...Ch. 12 - Write a program that creates Pet objects from data...Ch. 12 - Repeat the previous programming project, but sort...Ch. 12 - Repeat the previous programming project, but read...Ch. 12 - Prob. 9PPCh. 12 - Prob. 10PPCh. 12 - Prob. 11PPCh. 12 - Prob. 12PPCh. 12 - Prob. 13PPCh. 12 - Prob. 14PPCh. 12 - Prob. 15PP
Knowledge Booster
Background pattern image
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Text book image
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Text book image
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
Text book image
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Text book image
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Text book image
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education