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: 90% (10 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...
-
Assignment2 -InterviewingVictimsandWitnesses(10%) ThisassignmentrelatestothefollowingCourseLearningRequirements: CLR1-...
-
Consumer Price Index. The CPI measures the increase (or decrease) in the prices of goods and services relative to a base year. The CPI for the years 19902019 (using 1984 as a base period) is shown in...
-
After graduating from college, you and your friends start selling birdhouses made from recycled plastic. The idea has caught on, as shown by the following sales gures: MONTH DEMAND March..............
-
Beta Company is considering the purchase of a new equipment to automate part of their manufacturing process. The old system can be sold for $55,000. The new system will cost $4,500,000 and will last...
-
Ground jatropha hull samples were used to estimate the proxi- mate analysis. The following are the data from the experiment: An initial sample weighing 2.9657 g was used and placed in the drying oven...
-
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)
-
Statisticians sometimes report 50 percent confidence intervals, with the margin for sampling error called the probable error. For example, an estimate X of the average useful life of a television is...
-
Convert the following information into: a) a semantic net b) a frame-based representation A Ford is a type of car. Bob owns two cars. Bob parks his car at home.His house is in California, which is a...
-
Visit www.pearsonglobaleditions.com/malhotra to read the video case and view the accompanying video. Marriott: Marketing Research Leads to Expanded Offerings highlights Marriotts success in using...
-
The water level in a tank is \(20 \mathrm{~m}\) above the ground. A hose is connected to the bottom of the tank, and the nozzle at the end of the hose is pointed straight up. The tank cover is...
-
A simple experiment has long been used to demonstrate how negative pressure prevents water from being spilled out of an inverted glass. A glass that is fully filled by water and covered with a thin...
-
A golf ball is hit on a level fairway. When it lands, its velocity vector has rotated through an angle of 90. What was the launch angle of the golf ball? Pyo By Dyz =0 Uso Range R x max dya
-
Simplify. [(-4) 3 ] 6
-
Wimot Trucking Corporation uses the units-of-production depreciation method because units-of-production best measures wear and tear on the trucks. Consider these facts about one Mack truck in the...
-
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...
-
Billy Bob bank has three assets. It has $83 million invested in consumer loans with a 3-year duration, $46 million invested in T-Bonds with a 12-year duration, and $69 million in 6-month (0.5 years)...
-
Ventaz Corp manufactures small windows for back yard sheds. Historically, its demand has ranged from 30 to 50 windows per day with an average of 4646. Alex is one of the production workers and he...
-
Which of the following statements is not true regarding the $500 credit for dependent other than a qualifying child credit. Cannot be claimed on the same tax return if the child tax credit is also...
Study smarter with the SolutionInn App