Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please dont ask the question like that use cpp or other language. I choose java so if I use ohther language, it will be zero.

image text in transcribed

image text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribed

Please dont ask the question like that use cpp or other language. I choose java so if I use ohther language, it will be zero. Please write the code in java. Do not use ohther program language. In addition, for read files, using try and catch. For example, input a file name, if file name is wrong, the code cannot run.

The data of file:

AS 3D JH QD 6S 8H 3S 5H JD 9H 6H KC 5C 4D 7D 8S 4S AH 3H QS 6D 2S 9S 9C 3C 9D AC 2C 5S QC JS 7S JC 10C 7C 2D 4C AD KH 2H KS 8C 8D 4H 6C 10H KD QH 5D 7H 10S 10D

he output should like below:

Please enter a filename:

ex8.txt

Max length: 26

First card: 3D

Last card: 7H (but last card could differ)

This exercise is to be done before or during your week 12 laboratory class. When you complete the exercise show your work to your lab tutor to have your work marked. The marking is based mainly on correct implementation and code readability. You should implement your code in one file (e.g ex8.cpp, ex8.c, ex8.java). Make sure your program has a header comment block containing the name of the exercise, your name and your student login (e.g. jfk01). You may implement your solution in C, C++, Java or Python For this exercise, you are to solve the crazy 8s puzzle using Dynamic Programming as presented in the week 10B lecture As usual, your program will prompt for the name of an input file and the read and process the data contained in this file The file contains the following data 52 lines each containing the identity of a playing card in the form RS, where R is the Rank of the card (A, 2, 3, 4, 5, 6, 7, ..., 10, J, Q, K) and S is the Suit (C, D, H, S) 2C 10D QS AS JD SH The order of cards in the list is the shuffled order of the deck you are to solve, You are to solve the deck (find the longest allowable sequence of cards) and output The length of the longest sequence; The first card in the sequence; The last card in the sequence Remember: The sequence is allowed to skip cards, it is not allowed to re-order cards When you are finished, test your program using the provided text file named "Ex8.txt" and show your code and the output to your lab tutor to receive your mark This exercise is to be done before or during your week 12 laboratory class. When you complete the exercise show your work to your lab tutor to have your work marked. The marking is based mainly on correct implementation and code readability. You should implement your code in one file (e.g ex8.cpp, ex8.c, ex8.java). Make sure your program has a header comment block containing the name of the exercise, your name and your student login (e.g. jfk01). You may implement your solution in C, C++, Java or Python For this exercise, you are to solve the crazy 8s puzzle using Dynamic Programming as presented in the week 10B lecture As usual, your program will prompt for the name of an input file and the read and process the data contained in this file The file contains the following data 52 lines each containing the identity of a playing card in the form RS, where R is the Rank of the card (A, 2, 3, 4, 5, 6, 7, ..., 10, J, Q, K) and S is the Suit (C, D, H, S) 2C 10D QS AS JD SH The order of cards in the list is the shuffled order of the deck you are to solve, You are to solve the deck (find the longest allowable sequence of cards) and output The length of the longest sequence; The first card in the sequence; The last card in the sequence Remember: The sequence is allowed to skip cards, it is not allowed to re-order cards When you are finished, test your program using the provided text file named "Ex8.txt" and show your code and the output to your lab tutor to receive your mark

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Making Databases Work The Pragmatic Wisdom Of Michael Stonebraker

Authors: Michael L. Brodie

1st Edition

1947487167, 978-1947487161

More Books

Students also viewed these Databases questions

Question

18. If you have power, then people will dislike and fear you.

Answered: 1 week ago