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
A Solve each member force of the truss shown below. F 30 kN E 30 kN 3 m 3 m D C B 4 m 4 m 4 m 4 m
5:11 PM Fri Dec 13 Tt Problem 8 should be answered as a triple quoted comment after the code PROBLEM G. Put your name and assignment information here. The Bells Edgar Allen Poe HEAR the sledges with the bells. Siver bells! What a world of merriment their melody foretels How they tinkle, tinkle, tinkle, In the icy air of night While the stars, that oversprinkle All the heavens, seem to twinkle With a crystalline delight Keeping time, time, time. In a sort of Runic rhyme. To the tintinnabulation that so musically wells From the bells, bells, bells, bells, Bells, bells, bells From the jingling and the tinkling of the bells Hear the mellow wedding bels Golden bells! What a world of happiness their harmony foretells Through the balmy air of night How they ring out their delight! From the molten-golden notes. And all in tune. What a liquid ditty floats To the turtle-dove that stens, while she gloats On the moon! Oh, from out the sounding cells. What a gush of euphony voluminously wells! How…
1. Could you see yourself making a career out of being a System Analyst? why? 2. What is one question you have about being a system analyst still or the system analysis and design process?

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