Concept explainers
Which of the following expressions return true?
After writing your answers on paper, open the Code Pad in BlueJ and try it out. Check your answers,
Want to see the full answer?
Check out a sample textbook solutionChapter 3 Solutions
Objects First with Java: A Practical Introduction Using BlueJ (6th Edition)
Additional Engineering Textbook Solutions
Java How to Program, Early Objects (11th Edition) (Deitel: How to Program)
Concepts Of Programming Languages
Starting Out with Java: Early Objects (6th Edition)
Programming in C
Modern Database Management
Problem Solving with C++ (10th Edition)
- : You will build a simplified, one-player version of the classic board game Battleship! In this version of the game, there will be a single ship hidden in a random location on a 5 °ø 5 grid. The player will have 4 guesses at most to try to sink the ship. At each guess, the player names an attacking coordinate, that is (“guessrow”, “guess col”). The game ends in two conditions: (1) the player is out of guesses; (2) the player hits the ship. Examples are given in Figure 1. § The 5 X 5 board is shown every time the player inputs a guess entry. § The ship takes only one entry of the board, and it is randomly given before the player’s guesses. § The player inputs guessing entries in the Python console. § Entries that missed the ship are replaced by “X” on the board. § You must use a loop in your code. § Please submit your code and console screenshots to Blackboard. Code containing syntax error will be graded zero. Hints: 1. Create a variable board and set it equal to an empty list and…arrow_forwardWrite an expression that prints "Eligible" if userAge is between 18 and 25 inclusive.Ex: 17 prints "Ineligible", 18 prints "Eligible".arrow_forwardWrite an expression that prints "Eligible" if userAge is between 18 and 25 inclusive. Ex: 17 prints "Ineligible", 18 prints "Eligible".arrow_forward
- What is the value of the following expression? (15 (6*2+6)) || ((20/5+2) > 5) && (8 (2+3% 2))arrow_forwardQ2 / chose the right answer 1- a=3; b=5; c=7, enter ? (7/ 3,5,7/ 3,5) 2 - a=1:9; b=9-a; c= 0, enter ? ( 1,2,3,4,5,6,7,8,9 / 8,7,6,5,4,3,2,1,0 / 0) 3 - X(4+5) =9; Y(5-4) = 1; C = X+Y = ? (10 /8/ 11) { - Operator bitor (A, B) the Description is (Bitwise AND / Bitwise OR / Logical NOT) 5 - 100:-7:40 Matrix with one row is (100 93 76 79 72 65 58 81 16 / 100 93 86 79 72 65 58 51 46 / 100 23 86 79 72 35 58 51 46 )arrow_forwardA video player plays a game in which the character competes in a hurdle race. Hurdles are of varying heights, and the characters have a maximum height they can jump. There is a magic potion they can take that will increase their maximum jump height by unit for each dose. How many doses of the potion must the character take to be able to jump all of the hurdles. If the character can already clear all of the hurdles, return . Example The character can jump unit high initially and must take doses of potion to be able to jump all of the hurdles. Function Description Complete the hurdleRace function in the editor below. hurdleRace has the following parameter(s): int k: the height the character can jump naturally int height[n]: the heights of each hurdle Returns int: the minimum number of doses required, always or more Input Format The first line contains two space-separated integers and , the number of hurdles and the maximum height the character can jump naturally.The…arrow_forward
- Rules: Corner cases. By convention, the row and column indices are integers between 0 and n − 1, where (0, 0) is the upper-left site. Throw an IllegalArgumentException if any argument to open(), isOpen(), or isFull() is outside its prescribed range. Throw an IllegalArgumentException in the constructor if n ≤ 0. Unit testing. Your main() method must call each public constructor and method directly and help verify that they work as prescribed (e.g., by printing results to standard output). Performance requirements. The constructor must take Θ(n^2) time; all instance methods must take Θ(1)Θ(1) time plus Θ(1)Θ(1) calls to union() and find().arrow_forwardQuestion 3 Give the result of the following code: quotaThisMonth = 7 quotaLastMonth= quotaThisMonth + 1 if (quota This Month > quota LastMonth) or \ (quotaLastMonth >= 8): print("Yes") quotaLastMonth = quotaLastMonth +1 else: print("No") quotaThis Month = quotaThis Month Blank 1 Blank 1 Add your answerarrow_forwardWrite the following functions that fill a rectangle with the specified color, center, width, and height, and a circle with the specified color, center, and radius.# Fill a rectangledef drawRectangle(color = "black",x = 0, y = 0, width = 30, height = 30):# Fill a circledef drawCircle(color = "black", x = 0, y = 0, radius = 50):arrow_forward
- Create functional tests where arguments are given, use a parameterized test. testSimpleInit(size): the first constructor works as expected. getTiles shows suitable values. The edges of the board (the smallest and biggest conceivable values) are accessible and contain the values that they have to (BASE_TILE_SCORE). testCustomInit(x, y, expected): the second constructor works as expected. On positions where values smaller than three were passed, the board contains the value BASE_TILE_SCORE. If you pass an array to the constructor and later modify a value in it, the respective tile retains the originally passed value. If you modify an element in the return value of getTiles(), and get the value of the respective tile again, this newly received content has to be the originally set value. testMoves(): take four or five steps and check that the board’s contents are changed just right. Include a step that tries to move to the x coordinate Integer.MIN_VALUE and another one that moves to…arrow_forwardAfter the following code is executed, which of I, II and/or III will evaluate to true? int [] a1 = {2,3,4,5,6,7,8};int [] a2 = a1;a2[0] = 10; I. a1[0] == 10 II. a2[0] == 10 III. a1[0] == 2 Group of answer choices III only I only I, II, III II and III I and IIarrow_forwardhasAnEvenDigit: Takes an int (n) as parameter and returns whether n has at least one digit whose value is even. Return true if the number has at least one even digit else false if none of the digits are even. For example, the call hasAnEvenDigit(33267) should return true and hasAnEvenDigit(7591) should return false. [Hint: n%10 returns the last digit and n/10 returns everything except the last digit] class Main {public static void main(String[] args) {}}arrow_forward
- 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