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

Birds Survey

Program Plan:

  • Import required package.
  • Define “BirdSurvey” class.
    • Create object “headNode” from “ListNode”.
    • Create constructor for “BirdSurvey” class.
    • Define the method “getReport()”.
      • Compute position of node.
      • Check condition using “while” loop.
        • Display bird name and count.
    • Define the method “computeLength()”.
      • Set count to “0”.
      • Set “position” to “headNode”.
      • Check condition using “while” loop.
        • Increment count
      • Finally returns count value.
    • Define the method “addANodeToStart” which is used to add bird name at start of list by using “ListNode” class.
    • Define the method “add” with the argument of “bird”.
      • If head node is null, then add bird to the front of list.
      • Otherwise
        • Compute given bird name by calling the method “find” and then store result to “n”.
        • If “n” is null, then increment count value.
        • Otherwise, find the last node in the list.
      • Add in the node by using “ListNode” class.
    • Define the method “getCount” with the argument of “bird”.
      • Declare required variable.
      • Create list for nodelist.
      • If the bird is not on the list, then assign result of count to “0”.
      • Otherwise, compute the result associated with bird species.
      • Finally returns the value of result.
    • Define the method “onList” with the argument of “t”.
      • This method is used to check whether target “t” is on the list or not
    • Define the method “find” with the argument of “t”.
      • Assign required variables.
      • Check condition using “while” loop.
    • Define inner node class “ListNode”.
      • Declare required variables.
      • Create parameterized constructor for “ListNode” class.
        • Assign values to required variables.
    • Define main function.
      • Create object “bs” from “BirdSurvey” class.
      • Create object for scanner class.
      • Display statement.
      • Assign “moreValue” to “true”.
      • Check condition using “while” loop.
        • Read bird name from user.
        • If the bird name is “done”, then set “moreValue” to “false”.
        • Otherwise, add the bird name to “bs”.
      • Display the birds report by calling the method “getReport”.

Blurred answer
Students have asked these similar questions
Given the MileageTrackerNode class, complete main() in the MileageTrackerLinkedList class to insert nodes into a linked list (using the insertAfter() method). The first user-input value is the number of nodes in the linked list. Use the printNodeData() method to print the entire linked list. DO NOT print the dummy head node. Ex. If the input is: 3 2.2 7/2/18 3.2 7/7/18 4.5 7/16/18 the output is: 2.2, 7/2/18 3.2, 7/7/18 4.5, 7/16/18 public class MileageTrackerNode {   private double miles;         // Node data                                                            private String date;          // Node data   private MileageTrackerNode nextNodeRef; // Reference to the next node                                  public MileageTrackerNode() {      miles = 0.0;      date = "";      nextNodeRef = null;   }    // Constructor                                                                                        public MileageTrackerNode(double milesInit, String dateInit) {      this.miles =…
There’s a somewhat imperfect analogy between a linked list and a railroad train, where individual cars represent links. Imagine how you would carry out various linked list operations, such as those implemented by the member functions insertFirst(), removeFirst(), and remove(int key) from the LinkList class in this hour. Also implement an insertAfter() function. You’ll need some sidings and switches. You can use a model train set if you have one. Otherwise, try drawing tracks on a piece of paper and using business cards for train cars.
Programming in Java. What would the difference be in the node classes for a singly linked list, doubly linked list, and a circular linked list? I attached the node classes I have for single and double, but I feel like I do not change enough? Also, I use identical classes for singular and circular node which does not feel right. Any help would be appreciated.

Chapter 12 Solutions

Java: An Introduction to Problem Solving and Programming (7th 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 - 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
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning