Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Hello, i asked for a solution about this java tile game, but got very complicated answer. I need it only using character, string, if else

Hello, i asked for a solution about this java tile game, but got very complicated answer. I need it only using character, string, if else statements etc. Note that it is based on Zybook 1.1-3.21 which covers up things like variable, character, string , if-else, float, switch, boolean data type , conditional explanation, integer etc . input should be as given and please show the output if its matching. Thank you.image text in transcribedimage text in transcribedimage text in transcribed

Project 1: Tile Game NOTE: If you turn in a solution to this problem based on something from a pay-for-answers website such as Chegg, CourseHero, etc., you will receive an F in this course (not just on this assignment). Start early and seek help from a lab assistant, the help room, or your professor if you need it. If you don't have time to do that, it is better to get a low grade on the project than to cheat and fail the course. For this project you will write a domino-like tile game, where the objective is to determine the maximum score possible by arranging the tiles according to the scoring rules of the game. Input The game is played using tiles with numbers on each half, separated by a pipe symbol (the vertical line on the same key as the backslash). The numbers are always 1,2 or 3 . So, 3 1 is a valid tile, whereas 8 | 2 is not. For the game, you will be given two tiles separated by a space, a comma, and another space. Here is an example, but keep in mind that the numbers may be different on the set of tiles you receive during the game: 31,23 Hint: don't try to read this in as a single line. Instead, use a combination of nextInt and next to read in the different parts. Rules The game is to make a sequence out of these tiles such that the sum of the first and last numbers in the sequence times the number of tiles in the sequence results in the maximum possible. Tiles can only be used in the sequence if the numbers connecting them are the same. The order of the tiles is changeable, but individual tiles cannot be "flipped" such that the numbers on the left and right sides are reversed. Tiles can also be scored individually (a sequence of length one). In this example, we can have these configurations: 23,31(2+1)2=6 points 23>(2+3)1 = 5 points 31(3+1)1=4 points Note that we cannot use the sequence 31,23 because the numbers connecting the two tiles (1 and 2) are not the same. We also cannot "flip" the 31 tile so that it is 13, or the 23 so that it is 32. Write a program that prompts the user to enter the tiles they have (all on one line, in the format described above) by writing the word Input followed by a colon and a space to the screen. The program should then read in the user's input and compute the maximum possible score. Then it should write the word Output, a colon, and a space, followed by the sequence of tiles with the highest possible score, a space, an arrow (minus sign, followed by greater than sign), another space, and the number of points that the sequence of tiles is worth. In the example above, the program would output: Input: 3 | 1,2 | 3 Output: 2 | 3,316 points You can assume the tiles will be entered by the user in the appropriate format (with a pipe symbol between the numbers and separated by a space, comma, and another space), but your program should check to make sure that all numbers on the tiles are either 1,2 or 3 . If any number is outside of this range, display an error message to the user and quit: Input: 3 | 10,1 | 1 output: Invalid input, quitting... Input: 3&1,2&3 Your program may do anything in this situation, including hang or crash, since the input format is invalid (\& instead of I ) Input: 3 | 1,23,1 | 1 Your program may do anything in this situation, including hang or crash, since the input format is invalid (too many tiles) Input: 3 | 1 Your program may do anything in this situation, including hang or crash, since the input format is invalid (too few tiles) Rubric: Note: Code that does not compile will receive a zero. [20 pts] The program identifies / parses the two tiles entered by the user [10 pts] The program prints an error message if one of the tiles contains an invalid number [15 pts] The program correctly determines the score of a one-tile sequence [15 pts] The program correctly determines the score of a two-tile sequence [20 pts] The program checks for all possible scoring configurations / tile sequences [10 pts] Correctly prints out the sequence that will give the maximum score as well as the number of points associated with that sequence [10 pts] The program is clearly organized, commented, and follows standard coding practices, including using descriptive/meaningful variable and class names

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

Students also viewed these Databases questions