LISTING 19.6 import java.io.*; /** * BackPainAnaylyzer demonstrates the use of a binary decision tree to...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
LISTING 19.6 import java.io.*; /** * BackPainAnaylyzer demonstrates the use of a binary decision tree to * diagnose back pain. */ public class BackPainAnalyzer { } /** * Asks questions of the user to diagnose a medical problem. */ public static void main(String[] args) throws FileNotFoundException { System.out.println("So, you're having back pain."); } DecisionTree expert = new DecisionTree ("input.txt"); expert.evaluate(); OUTPUT So, you're having back pain Did the pain occur after a blow or jolt? Y Do you have difficulty controlling your arms or legs? N Do you have pain or numbness in one arm or leg? Y You may have a muscle or nerve injury. import jsjf.*; import java.util. *; import java.io.*; * * The DecisionTree class uses the LinkedBinaryTree class to implement a binary decision tree. Tree elements are read from a given file and then the decision tree can be evaluated based on user input using the * evaluate method. * * * @author Java Foundations *@version 4.0 */ public class DecisionTree { private LinkedBinaryTree tree; /** * Builds the decision tree based on the contents of the given file * @param filename the name of the input file * @throws FileNotFoundException if the input file is not found */ public DecisionTree (String filename) throws FileNotFoundException { * File inputFile = new File (filename); Scanner scan = new Scanner (inputFile); } int numberNodes scan.nextInt (); scan.nextLine(); int root = 0, left, right; List nodes = new java.util.ArrayList (); for (int i = 0; i < numberNodes; i++) nodes. add (i, new LinkedBinaryTree (scan.nextLine())); while (scan.hasNext()) { root scan.nextInt (); left scan.nextInt (); right scan.nextInt (); scan.nextLine(); nodes. set (root, new LinkedBinaryTree ((nodes.get (root)).getRootElement (), nodes.get (left), nodes.get (right))); } tree nodes.get (root); * Follows the decision tree based on user responses. */ public void evaluate () { LinkedBinaryTree current = tree; Scanner scan = new Scanner (System.in); while (current.size() > 1) { System.out.println (current.getRootElement()); if (scan.nextLine().equalsIgnoreCase ("N")) current = current.getLeft (); else current = current.getRight (); System.out.println (current.getRootElement()); import java.io.*; /** * BackPainAnaylyzer demonstrates the use of a binary decision tree to * diagnose back pain. */ public class BackPainAnalyzer { /** * Asks questions of the user to diagnose a medical problem. */ public static void main (String[] args) throws FileNotFoundException { System.out.println ("So, you're having back pain."); DecisionTree expert = new DecisionTree ("input.txt"); expert.evaluate(); LISTING 19.6 import java.io.*; /** * BackPainAnaylyzer demonstrates the use of a binary decision tree to * diagnose back pain. */ public class BackPainAnalyzer { } /** * Asks questions of the user to diagnose a medical problem. */ public static void main(String[] args) throws FileNotFoundException { System.out.println("So, you're having back pain."); } DecisionTree expert = new DecisionTree ("input.txt"); expert.evaluate(); OUTPUT So, you're having back pain Did the pain occur after a blow or jolt? Y Do you have difficulty controlling your arms or legs? N Do you have pain or numbness in one arm or leg? Y You may have a muscle or nerve injury. import jsjf.*; import java.util. *; import java.io.*; * * The DecisionTree class uses the LinkedBinaryTree class to implement a binary decision tree. Tree elements are read from a given file and then the decision tree can be evaluated based on user input using the * evaluate method. * * * @author Java Foundations *@version 4.0 */ public class DecisionTree { private LinkedBinaryTree tree; /** * Builds the decision tree based on the contents of the given file * @param filename the name of the input file * @throws FileNotFoundException if the input file is not found */ public DecisionTree (String filename) throws FileNotFoundException { * File inputFile = new File (filename); Scanner scan = new Scanner (inputFile); } int numberNodes scan.nextInt (); scan.nextLine(); int root = 0, left, right; List nodes = new java.util.ArrayList (); for (int i = 0; i < numberNodes; i++) nodes. add (i, new LinkedBinaryTree (scan.nextLine())); while (scan.hasNext()) { root scan.nextInt (); left scan.nextInt (); right scan.nextInt (); scan.nextLine(); nodes. set (root, new LinkedBinaryTree ((nodes.get (root)).getRootElement (), nodes.get (left), nodes.get (right))); } tree nodes.get (root); * Follows the decision tree based on user responses. */ public void evaluate () { LinkedBinaryTree current = tree; Scanner scan = new Scanner (System.in); while (current.size() > 1) { System.out.println (current.getRootElement()); if (scan.nextLine().equalsIgnoreCase ("N")) current = current.getLeft (); else current = current.getRight (); System.out.println (current.getRootElement()); import java.io.*; /** * BackPainAnaylyzer demonstrates the use of a binary decision tree to * diagnose back pain. */ public class BackPainAnalyzer { /** * Asks questions of the user to diagnose a medical problem. */ public static void main (String[] args) throws FileNotFoundException { System.out.println ("So, you're having back pain."); DecisionTree expert = new DecisionTree ("input.txt"); expert.evaluate();
Expert Answer:
Related Book For
Smith and Roberson Business Law
ISBN: 978-0538473637
15th Edition
Authors: Richard A. Mann, Barry S. Roberts
Posted Date:
Students also viewed these programming questions
-
The Company XYZ has 1173 blocks of building for its business operation, where each block has 7 floors. The distance between each floor is 7 meters. ] (ii) Give a function run2diff which can be...
-
A ball is thrown from the roof of a 1 0 0 m high building at a speed of 1 0 m / s making 3 0 angles with the horizontal. A child waiting on the ground at the door of the building falls into a coma...
-
a. General Mills, Inc., the large manufacturer of packaged foods, reported the following in its annual report for the year ending May 29, 2011 (in millions): Short-term borrowing .. $1,342.6...
-
Find the perimeter or area of the indicated figure. Area: trapezoid, b 1 = 67.2 in., b 2 =126.7 in., h = 34.2 in.
-
Describe the role of an organizations personnel in compliance and antifraud efforts.
-
(Entries for Retirement and Issuance of Bonds) Robinson, Inc. had outstanding $5,000,000 of 11% bonds (interest payable July 31 and January 31) due in 10 years. On July 1, it issued $7,000,000 of...
-
2. (7pts) Give an example of a 44 matrix A which have the following properties: (a) A is lower triangular. All its entries are integers. (b) A has two distinct eigenvalues. Each eigenvalue is a digit...
-
Kitchen World Inc. is a Canadian controlled private corporation (CCPC) that operates a retail business selling cooking utensils, knives and small appliances for both professional chefs and home...
-
There is no agreement internationally on how to address the issue of auditor liability. Required: Describe the approach taken in your own country (US) in addressing the issue of auditor liability and...
-
Maria looping menu fot a file editing program. thr looping menu supports three options: Read, Write, or Quit. Any possible exceptions should be handled with Try/Except blocks. the read() and write()...
-
Give an easy to understand example of the following exemptions to hearsay under the "prior statement of testifying witnesses" rule: "A prior statement made by a testifying witness who is subject to...
-
Governing Law and Jurisdiction: a. Specify the jurisdiction and venue for any disputes arising from the agreement. b. State the governing law that will be used to interpret and enforce the agree.?
-
Do you think a different type of culture might have helped some companies (like VW) avoid compliance failures? Are there any key differences between the compliance failures of VW and Chipotle?
-
Draft a proposed order for the court's signature on the hearing on our Motion to Compel that was granted by Judge Day on Feb 2, 2023. The Defendant, Spiderman , must turn over his personal bank...
-
Q4- Water in piston cylinder system at (T1 and XI). The water is heated isothermally until the (V2-4V1). Then the work is exchanged with system according the low (PV-C) until reach to its original...
-
The MIT Sloan School of Management is one of the leading business schools in the U.S. The following table contains the tuition data for the masters program in the Sloan School of Management. a. Use...
-
In the afternoon of September 6, 1999, an explosion leveled the home of Jerry Usovsky (Usovsky) in Richland, Iowa. Tragically, seven people who had gathered in the home to celebrate the Labor Day...
-
Horns Crane Service furnished supplies and services under a written contract to a partnership engaged in operating a quarry and rock-crushing business. Horn brought action against Prior and Cook, the...
-
Discuss the concept and importance of negotiability.
-
Online electronics retailer Kogan has announced an initial public offering to raise $50 million, with plans to list on the ASX at the end of June. Kogan, founded in 2006, said it would have a market...
-
For each company below, fill in the missing data. Each company is independent. Sales Beginning finished goods Cost of goods manufactured Ending finished goods Cost of sales Income Statement Company X...
-
Innovative Computers Pty Ltd began manufacturing inexpensive computers for the student market on 1 July 2018. The variable costs of manufacturing each computer are as follows. During the year ended...
Study smarter with the SolutionInn App