Listing 28.14, NineTail.java, presents a solution for the nine tails problem. Revise this program for the 4
Question:
Listing 28.14, NineTail.java, presents a solution for the nine tails problem. Revise this program for the 4 * 4 16 tails problem. Note that it is possible that a solution may not exist for a starting pattern. If so, report that no solution exists.
Listing
Transcribed Image Text:
1 import java.util.Scanner; 2 3 public class NineTail { 4 public static void main(String[] args) { // Prompt the user to enter nine coins' Hs and Ts System.out.print("Enter the initial nine coins Hs and Ts: "); Scanner input = new Scanner(System.in); String s = input.nextline(); char[] initialNode = s.toCharArray(); 10 11 12 13 14 15 16 17 18 19 20 } NineTailModel model = new NineTailModel(); java.util.List
1 import java.util.Scanner; 2 3 public class NineTail { 4 public static void main(String[] args) { // Prompt the user to enter nine coins' Hs and Ts System.out.print("Enter the initial nine coins Hs and Ts: "); Scanner input = new Scanner(System.in); String s = input.nextline(); char[] initialNode = s.toCharArray(); 10 11 12 13 14 15 16 17 18 19 20 } NineTailModel model = new NineTailModel(); java.util.List path = model.getShortestPath(NineTai1 Model.getIndex(initialNode)); System.out.println("The steps to flip the coins are "); for (int i = 0; i < path.size(); i++) NineTailModel.printNode( NineTail Model.getNode (path.get(i).intValue()));
Fantastic news! We've Found the answer you've been seeking!
Step by Step Answer:
Answer rating: 77% (9 reviews)
Program Plan Create class Exercise2813 which is the revised version of nine tails problem for sixteen tails which is mentioned in listing 2814 Create an inner static class TailModel which defines a mo...View the full answer
Answered By
Somshukla Chakraborty
I have a teaching experience of more than 4 years by now in diverse subjects like History,Geography,Political Science,Sociology,Business Enterprise,Economics,Environmental Management etc.I teach students from classes 9-12 and undergraduate students.I boards I handle are IB,IGCSE, state boards,ICSE, CBSE.I am passionate about teaching.Full satisfaction of the students is my main goal.
I have completed my graduation and master's in history from Jadavpur University Kolkata,India in 2012 and I have completed my B.Ed from the same University in 2013. I have taught in a reputed school of Kolkata (subjects-History,Geography,Civics,Political Science) from 2014-2016.I worked as a guest lecturer of history in a college of Kolkata for 2 years teaching students of 1st ,2nd and 3rd year. I taught Ancient and Modern Indian history there.I have taught in another school in Mohali,Punjab teaching students from classes 9-12.Presently I am working as an online tutor with concept tutors,Bangalore,India(Carve Niche Pvt.Ltd.) for the last 1year and also have been appointed as an online history tutor by Course Hero(California,U.S) and Vidyalai.com(Chennai,India).
4.00+
2+ Reviews
10+ Question Solved
Related Book For
Introduction to Java Programming, Comprehensive Version
ISBN: 978-0133761313
10th Edition
Authors: Y. Daniel Liang
Question Posted:
Students also viewed these Computer science questions
-
The program in Listing 28.14 lets the user enter an input for the nine tails problem from the console and displays the result on the console. Write a program that lets the user set an initial state...
-
The nine tails problem in the text uses a 3 * 3 matrix. Assume that you have 16 coins placed in a 4 * 4 matrix. Write a program to find out the number of the starting patterns that dont have a...
-
Rewrite Programming Exercise 28.14 to enable the user to set an initial pattern of the 4 * 4 16 tails problem (see Figure 28.23a). The user can click the Solve button to display the solution, as...
-
Timco is considering the construction of a new retail outlet. The construction cost will be 400000. Net working capital will increase by 10000. The depreciation is 10 year MACRS. The new location...
-
All cells contain an enzyme called peptidyl-tRNA hydrolase, and cells that are deficient in the enzyme grow very slowly. What is the probable function of the enzyme and why is it necessary?
-
Solve the linear programming problems stated in Problem. Maximize subject to P = 30x + 12y 3x + y 18 x, y = 0
-
Northern Group, Inc., is a Wisconsin corporation that contracts with manufacturers and suppliers to develop marketing strategies and promotions to third-party retailers. In exchange for these...
-
The comparative balance sheet of Mills Engine Co. at December 31, 2013 and 2012, is as follows: The noncurrent asset, noncurrent liability, and stockholders equity accounts for 2010 are as follows:...
-
Briefly describe TWO (2) drawbacks of NoSQL in comparison with RDBMS ?
-
Krystal is a U.S.-based company which manufactures, sells, and installs water purification equipment. On April 11th the company sold a system to the City of Nagasaki, Japan, for installation in...
-
Write a program that reads a connected graph from a file. The graph is stored in a file using the same format specified in Exercise. Your program should prompt the user to enter the name of the file,...
-
Given an undirected graph G = (V, E) and an integer k, find an induced subgraph H of G of maximum size such that all vertices of H have a degree > = k, or conclude that no such induced subgraph...
-
Determine the steady-state temperatures of two radiation shields placed in the evacuated space between two infinite planes at temperatures of 600 and 325 K. All the surfaces are diffuse and gray with...
-
Suppose you buy a bond with a coupon of 9.4 percent today for $1,120. The bond has 5 years to maturity. a. What rate of return do you expect to earn on your investment? (Do not round intermediate...
-
Loan payments of $6000 due 100 days ago and $5000 due 45 days ago are to be replaced by a payment of $5000 today and the balance 50 days from today. If the interest rate is 5% and the agreed focal...
-
It's your one-year anniversary at BPW! The supply chains that you have developed and maintained appear to be functioning well but a meeting with the sales team leaves the impression that quality...
-
Calculating Future Values a. Compute the future value of $1,000 compounded annually for 20 years at 7 percent. (Do not round intermediate calculations and round your answer to 2 decimal places, e.g.,...
-
What two traditional marketing methods would be most effective for Gen X families? This is for a retention marketing plan for existing Verizon wireless customers in the US.
-
Bathworks produces hair and bath products. Bathworks' owner would like to have an estimate of the company's net income in the coming year. Required Project Bathworks's net income next year by...
-
The following items were displayed in the statement of affairs for Lubbock Company: Fully secured liabilities ......... $90,000 Partially secured liabilities ....... 12,000 Unsecured liabilities...
-
What is meant by the term route aggregation? Why is it useful for a router to perform route aggregation?
-
What is meant by a plug-and-play or zeroconf protocol?
-
What is a private network address? Should a data-gram with a private network address ever be present in the larger public Internet? Explain.
-
You are working in an automotive workshop. Three (3) clients have brought in three (3) different vehicles that require diagnosis and repairs to the suspension systems and components. Your task is to...
-
5. Part 2: Torsion testing The aim of the torsion test is to find the shear modulus, yield and ultimate shear strength for the specimen material. Use the supplied dataset that matches with the LAST...
-
4. Part 1: Tensile testing The aim of the tensile test is to find the yield and ultimate tensile strengths and corresponding normal strains of the test material. This enables the prediction of the...
Study smarter with the SolutionInn App