Use the material from Section 10.3 to reimplement the animal-guessing program from Figure 9.8 as a JApplet.
Question:
Use the material from Section 10.3 to reimplement the animal-guessing program from Figure 9.8 as a JApplet. You’ll need to research additional details of the Java classes.
Transcribed Image Text:
FIGURE 9.8 The Animal-Guessing Program Java Application Program // FILE: Animal.java // This animal-guessing program illustrates the use of the binary tree node class. import edu.colorado.nodes.BTNode; // For BTNode
FIGURE 9.8 The Animal-Guessing Program Java Application Program // FILE: Animal.java // This animal-guessing program illustrates the use of the binary tree node class. import edu.colorado.nodes.BTNode; // For BTNode import java.util.Scanner; public class Animal { private static Scanner stdin = new Scanner(System.in); public static void main(String[ ] args) { BTNode root; instruct( ); root = beginningTree( ); do play(root); while (query("Shall we play again?")); System.out.println("Thanks for teaching me a thing or two."); } public static void instruct( ) I| The implementati on of this method is omitted write it yourself! public static void learn(BTNode current) || The implementation of this method is Self-Test Exercise 9. public static void play (BTNode current) { while (!current.isLeaf( )) { if (query(current.getData( ))) current = current.getleft(); else current = current.getRight( ); "); System.out.print("My guess is " + current.getData( ) + if (!query("Am I right?")) learn(current); else System.out.println("I knew it all along!"); }
Fantastic news! We've Found the answer you've been seeking!
Step by Step Answer:
Answer rating: 88% (9 reviews)
import javaxswing import javaawt import javaawtevent public class AnimalGuessing extends JApplet implements ActionListener private static final long s...View the full answer
Related Book For
Question Posted:
Students also viewed these Computer science questions
-
The Hampshire Company manufactures umbrellas that sell for $12.50 each. In 2014, the company made and sold 60,000 umbrellas. The company had fixed manufacturing costs of $216,000. It also had fixed...
-
You are the Chairperson of the Business Program at InterState Community College (ICC). Recently it has come to that attention of ICC Administration that there is a need for Project Management...
-
BACKGROUND You are an information analyst working for NEE. The company president has asked you to prepare a Quantitative analysis of financial, sales, and operations data to help determine which...
-
Complete the attached SWOT Worksheet using information from the Cotopaxi case. Use your SWOT Worksheet to help you answer the question: What should Davis Smith/Cotopaxi do (for company...
-
A local power commission sent a survey to homeowners to determine household power efficiency. Following is a list of major electrical appliances and their total kilowatt-hour (kWh) usage for one...
-
Refer back to Problem 10-7. Suppose that the toll bridge can be redesigned such that it will have a (virtually) infinite life. MARR remains at 10% per year. Revised costs and revenues (benefits) are...
-
Be aware of your environment. What do you think this statement means for an organization? What are implications for managing the external environment?
-
McDonald's Corporation franchises and operates more than 36,000 fast-service restaurants around the world. Buffalo Wild Wings franchises and operates more than 1,000 restaurants in North America....
-
Determine the amount of the standard deduction for the following taxpayer for tax year 2022: Lauren, who earned $1,600 working a part-time job. She can be claimed as a dependent by her parents.
-
Questions 1. Identify the steps of the product design process used by Harveys. (Specifically, consider market analysis, concept development, prototype development, and (external) testing and...
-
The java.lang.Math class provides a static method log(x), which returns the logarithm of x with a base that is approximately 2.718282..7This base is written e, and the logarithms with this base are...
-
Use the DefaultMutableTreeNode to reimplement one of these Chapter 9 projects: a. Expression trees (9.1) b. Bag of strings (9.10)
-
The idea for YouCastr was hatched in mid-2006, during a road trip involving Ariel Diaz, Jay Peak, and Jeff Dwyer. Throughout the ride, the friends bounced business ideas off each other. One idea...
-
Why is the cyclically adjusted budget balance a better measure of whether government policies are sustainable in the long run than the actual budget balance is?
-
Why does a recent graduates first job matter for his or her long-term earnings, even if he or she only stays at that job for three years?
-
Provide an example of a purchasing situation in which you think your own short and long-run elasticities differ a lot and a second in which they are similar. What drives those differences?
-
Economists predict that my interest in purchasing a convertible also depends on how much I think other people like convertibles. How is this prediction related to the durability of cars?
-
Critically evaluate the relative effectiveness of on-the-job training and off-the-job training.
-
When she is about to leave a restaurant counter, Mrs. Albanese sees that she has one penny, one nickel, one dime, one quarter, and one half-dollar. In how many ways can she leave some (at least one)...
-
The comparative statements of financial position of Menachem NV at the beginning and end of the year 2019 appear below. Net income of ¬34,000 was reported, and dividends of ¬23,000 were paid...
-
In this exercise, we examine how pipelining affects the clock cycle time of the processor. Problems in this exercise assume that individual stages of the datapath have the following latencies: Also,...
-
In this exercise, we examine how data dependences affect execution in the basic 5-stage pipeline described in Section 4.5. Problems in this exercise refer to the following sequence of instructions:...
-
In this exercise, we examine how resource hazards, control hazards, and Instruction Set Architecture (ISA) design can affect pipelined execution. Problems in this exercise refer to the following...
-
Fill in the 16 bit result of each of the following bit level expressions Ox1234 | Oxabcd Ox 0x2345 >> 1 Ox Oxabcd Oxabcd 0x Ox2345 & (0xff < < 4) Ox
-
How do theories of globalization, such as world-systems theory, cosmopolitanism, and cultural hybridity, analyze the interconnectedness of global processes and the transformations of local cultures,...
-
3. Let = {0, 1}, construct a finite automata for: L= (0+1)+(0+1) 2
Study smarter with the SolutionInn App