
Database System Concepts
7th Edition
ISBN: 9780078022159
Author: Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher: McGraw-Hill Education
expand_more
expand_more
format_list_bulleted
Question
I need help with creating a Java
Minesweeper.
Write a program that reads three numbers, m, n, and p and produces an m-by-n Boolean
array where each element is occupied with probability p. In the minesweeper game, occupied
cells represent bombs and empty cells represent safe cells.
Print out the array using an asterisk for bombs and a period for safe cells.
Then, create an integer two-dimensional array with the number of neighboring bombs (above,
below, left, right, or diagonal).
Write a program that reads three numbers, m, n, and p and produces an m-by-n Boolean
array where each element is occupied with probability p. In the minesweeper game, occupied
cells represent bombs and empty cells represent safe cells.
Print out the array using an asterisk for bombs and a period for safe cells.
Then, create an integer two-dimensional array with the number of neighboring bombs (above,
below, left, right, or diagonal).
* * . . . * * 1 0 0
. . . . . 3 3 2 0 0
. . . . . 3 3 2 0 0
. * . . . 1 * 1 0 0
Write your code so that you have as few special cases as possible to deal with, by using an
(m+2)-by-(n+2) Boolean array.
Write your code so that you have as few special cases as possible to deal with, by using an
(m+2)-by-(n+2) Boolean array.
Expert Solution

This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
This is a popular solution
Trending nowThis is a popular solution!
Step by stepSolved in 4 steps with 8 images

Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Similar questions
- Write a program in c that create a 5-by-6 array. All elements in the array are random integer numbers between 1 and 100. Then, calculate the mean values of each column, and also find the minimums and maximums of each column. Print out the array, mean values, minimums,arrow_forwardWrite a Java program that asks the user to enter the size for an Array. Then fill the array with the arithmetic series that starts at 3.5 and goes up by 3. (Hint: use for loop). Display the sum of all the numbers in the array. Display the Average of all the numbers in the array.arrow_forwardWrite a program in Java that reads integers, one per line, and displays their sum. Also, display all the numbers read, each with an annotation giving its percentage contribution to the sum. Use a method that takes the entire array as one argument and returns the sum of the numbers in the array. (Hint: Ask the user for the number of integers to be entered, create an array of that length, and then fill the array with the integers read.arrow_forward
- An array is declared as short Lot[67]. The address of Lot is 0x2877. What is the address of Lot[40]? Give your answer in 4 hexadecimal digits (include leading zeros). An array is declared as int State[29]. The address of State is 0xF988. What is the address of State[21]? Give your answer in 4 hexadecimal digits (include leading zeros). An array is declared as short Night[29]. The address of Night is 0xBE47. What is the address of Night[26]? Give your answer in 4 hexadecimal digits (include leading zeros).arrow_forwardwrite in java pleasearrow_forwardComputer Science Questionarrow_forward
- Java Program to Print Elements Which Occur Odd Number of Times. Given an array of integers, print all the elements whose frequency are odd. Example: Array = [5, 4, 4, 2, 1] Output: 5 2 1.arrow_forwardConsider an array of length n containing unique integers in random order and in the range 1 to n + 1. For example, an array of length 5 would contain 5 unique integers selected randomly from the integers 1 through 6. Thus, the array might contain 3 6 5 1 4. Of the integers 1 through 6, notice that the 2 was not chosen and is not in the array. Write Java code that finds the integer that does not appear in such an array. Your solution should use a. O(n²) operationsarrow_forwardWrite a JAVA program that plays a simple trivia game. The game should have five questions. Each question has a corresponding answer and point value between 1 and 3 based on the difficulty of the question. Implement the game using three arrays. An array of type String should be used for the questions. Another array of type String should be used to store the answers. An array of type int should be used for the point values. All three arrays should be declared to be of size 5. The index into the three arrays can be used to tie the question, answer, and point value together. For example, the item at index 0 for each array would correspond to question 1, answer 1, and the point value for question 1. The item at index 1for each array would correspond to question 2, answer 2, and the point value for question 2, and so forth. Manually hardcode the five questions, answers, and point values into your program using trivia of your choice. Your program should ask the player each question one at a…arrow_forward
- Write a java program that: • Reads 10 integer numbers and store them in an array of size 10. • Find and display how many numbers in the array divisible by 2. • Print those numbers on the screen. • Find and display the average of all odd numbers in the array. Sample Input/Output: Enter 10 numbers: 1 2 4 2 5 7 30 11 3 21 There are 4 numbers divisible by 2. Those are : 2 4 2 30 The average of odd numbers in the list is 8arrow_forwardIn this assignment, you will write a Java program that counts the 26 letter frequencies for a given string. You may name your Java file name as LetterCounter ArrayApp.java, and write methods that use arrays to store the frequencies. The detailed descriptions are as follows: • Method 1: countLetters() /* * Return an array of 26 letters’ frequencies for a given string * * Note: You only need count the frequency for 26 letters * i.e., "abcdefghijklmnopqrstuvwxyz". * you should count both uppercase and lower case letters */ public static int [] countLetters(String str) { // your work } • Method 2: printLetterFreq() /* * Print the letters, their frequencies, and frequency representations * @countArray: an array of 26 letters frequencies in an alphabetic order * * Note: Only print those frequencies > 0. */ public static void printLetterFreq(int [] countArray) { // your work } 1 • Method 3: numToStar(int num) /* * Return a string with a number of stars (*) corresponding to the input *…arrow_forwardFor Java. Create a program that can read N integer numbers, store them in an array and then use a method to calculate and return the average of all numbers. Refer to photo.arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education

Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education

Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON

Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON

C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON

Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning

Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education