Question: Hey, need help with this assignment set, they are all to be programmed in Java , thanks! AP COMPUTER SCIENCE A EXTRA PRACTICE FOR 2D


Hey, need help with this assignment set, they are all to be programmed in Java, thanks!
AP COMPUTER SCIENCE A EXTRA PRACTICE FOR 2D ARRAYS For this set of problems, you will have the freedom to show evidence of your planning in any way you see fit. We have already covered pseudocode, flowcharts, and truth tables as common methods for planning code prior to writing code. For each of these exercises, develop a plan BEFORE you begin coding. Once you begin coding, be sure to comment your code. You may need to implement multiple methods. If you choose to write pseudocode, you may use the lines of pseudocode as the comments for your code to show how it was translated. 1. You are given a two-dimensional array of values that give the height of a terrain at different points in a square. Write a method public static void floodMap (double[][] heights, double waterLevel) that prints out a flood map, showing which of the points in the terrain would be flooded if the water level was the given value. In the flood map, print a * for each flooded point and a space for each point that is not flooded. Then write a program that reads one hundred terrain height values and shows how the terrain gets flooded when the water level increases in ten steps from the lowest point in the terrain to the highest. The sample print out below on the right would be the 5th step when using the heights provided in the table. Here is a sample map of the terrain (heights) and sample print out from the floodMap method (you may simply highlight this data table then copy and paste into the console to test your code): 2.1 5.5 5.5 5.5 4.1 5.5 5.5 5.5 4.1 2.1 Water level: 10.8 ********** 5.2 0.3 6.5 6.8 6.5 3.8 4.6 4.2 1.3 1.2 ********** 0.1 8.9 8.9 7.8 6.8 5.6 4.6 4.1 1.1 0.7 ********** * ****** 10.3 11.3 8.4 11.0 12.3 9.9 1.3 0.6 0.1 -3.0 ******** 12.5 10.2 9.7 12.6 8.4 7.3 1.5 0.1 0.0 -5.0 ******* 18.6 10.1 16.8 -8.0 9.2 8.3 6.5 1.2 0.0 -3.0 **** **** 25.4 23.6 19.8 14.5 12.6 11.2 6.5 0.0 -5.0 -12.0 *** 30.7 31.5 25.3 21.3 18.5 14.3 4.5 1.2 0.0 -3.0 0.0 40.2 35.6 26.4 22.3 19.3 16.2 11.2 8.6 -2.2 45.0 30.0 40.0 32.0 21.0 14.0 12.0 10.0 11.0 10.0 2. A theater seating chart is implemented as a two-dimensional array of ticket prices, like this: 10 10 10 10 10 10 10 10 10 10 10 H. 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 20 20 20 20 20 20 10 10 10 10 20 20 20 20 20 20 10 10 10 10 20 20 20 20 20 20 10 10 20 20 30 30 40 40 30 30 20 20 20 30 30 40 50 50 40 30 30 20 30 40 50 50 50 50 50 50 40 30 Write a program that prompts users to pick either a seat (formatted by row #, then seat #, e.g. A 5) or a price. Mark sold seats by changing the price to 0. When a user specifies a seat, make sure it is available. When a user specifies a price, find any seat with that price. Reprint the chart with the updated selection and ask the user if they would like another seat. Continue to sell seats until it is sold out or the user chooses to end/exit the program (provide an appropriate sentinel). 3. Magic squares. An n x n matrix that is filled with the numbers 1, 2, 3, ..., n? is a magic square if the sum of the elements in each row, in each column, and in the two diagonals is the same value. Write a program that reads in 16 values from the user, places them into a 4 x 4 matrix, and tests whether they form a magic square (placing them into rows - so the first 4 ints is the first row of the square). You need to implement two methods and test two features: 1. Do each of the numbers 1, 2, 16 occur once in the user input? If not, you do not need to check part 2. public static boolean allSixteen (int [] [] nums) 2. When the numbers are put into a square, do the numbers form a magic square? That is - are the sums of the rows, columns, and diagonals equal to each other? public static boolean isSquareMagic (int [] [] nums) This should print the formatted number square and whether the square is a magic square. SAMPLE: This input IS a magic square: This input IS NOT a magic square: 16 2 3 13 5 11 10 8 9 7 6 124 14 15 1 16 9 6 3 5 4 15 10 11 14 281712 13
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
