int sum = 0; int i = 0; while (i < 4) {sum = sum + i; i++; } %3D %3D %3D 3D
Q: In geometry, polygons are defined as plane (two-dimensional) and closed shapes that are formed by…
A: In the Below steps you can complete code and output.
Q: QUESTION 4 Array length vs String length Array length is a field String length is a field Array…
A: The given questions ask distinction between length field & length method.
Q: UML Diagrams Shape (interface) + getPerimeter() : double + getArea(): double + getDetails() : void…
A: Triangle.java: public class Triangle { int sideA,sideB,sideC; public Triangle(int sideA, int sideB,…
Q: Using Java create a method that generates an array of random numbers
A: The random number is generated in Java using the Random class of the java.util.package. An instance…
Q: Write a test program that prompts the user to enter two 2 * 2 matrices and displays their sum. Here…
A: import java.util.Scanner; public class Tester{ public static void main(String[] args) { Scanner…
Q: // TODOd: define a "board" member variable (private) as a 2D char array of BOARD_SIZE x BOARD_SIZE…
A: A 2D char array is a two-dimensional array where all elements are of character data type. The syntax…
Q: The variable "“Image" is a two dimensional array of structures containing the pixel values of a…
A: C Program:#include<stdio.h> struct Pixel{ int Red,Green,Blue;};int main(){ // initialize…
Q: Programming language is "C" : ( with comments please, The comments is very important): (( 30…
A: #include<stdio.h> int main() // main function { int arr[30],…
Q: Use Java programming language Write a program that asks the user to enter 5 test grades (use an…
A: In this question, we are asked to write a java program which call the 6 separate methods for the…
Q: 3. Suppose you have been hired to develop a musical chair game. In this game there will be 7…
A: Input : Number of players i.e. 7 Name of each player Output : Start the game Remove the player…
Q: nt: esents a coordinate point on the playing field grid." LON init_(self, x: float, y: float):…
A: I have written code below:
Q: Print function can be used to print any statement on the 2. is a method graphic specifies to draw…
A: just see the below answers for you questions.
Q: Use Visual Basic Write a RainFall program that stores the total rainfall for each of 12 months into…
A: import java.util.Scanner;class rainFall { public static void main(String[] args) { Scanner keyboard…
Q: A double left rotation requires a single Type your answer here rotation followed by a single Type…
A: left rotation followed by right rotation
Q: Random rand-new Random(); int num= ; Fill in the blank to assign a random number between 25 and 75…
A: Code:
Q: #include #include Edouble coneSurfaceArea (double radius , double height , double pi) { double surf…
A: - We have to correct the code and build it correctly.
Q: Direction Fields Plotting Direction fields can be done using the function quiver quiver Quiver plot.…
A: %% MATLAB code for given problem :- % for item no.1 xr1 = -5:0.5:5; % the value of x is from -5 up…
Q: The size of an array (how many elements it contains), which is accessed by .Length() returns (Choose…
A:
Q: Java. Only need the calculate sum part. Please use the template, thank you!
A: Here I have defined the function sum(). In this function, I have checked the value of horizontal.…
Q: Part 2. f. Create a new StringBuilder Object using no-arg constructor. g. Using for loop append the…
A: Solution: Given,
Q: Explain the problem with the following code: int a[] = {1, 2, 3, 4, 5}; a[5] = 10; cout << a[5] <<…
A: I have given an answer in step 2.
Q: Data stored within an object is known as a(n) method O class O instantiation O data element
A: The correct is ("class") Option "B"ExplanationObject Storage is a means to handle and control data…
Q: Write a java program to find the 2nd largest number in the array and explain program with comments.
A: As per the guidelines, only 1st question is answered in case of multiple questions. For other…
Q: Tetris is a famous puzzle video game. The objective of the game is to complete lines by moving…
A: The program for the problem is given below: def tetris(grid): width = 0 total_full_lines = 0 for i…
Q: Seatwork BUG BUSTER: What is wrong with the following code fragment? int x,y; int array[10][3];…
A: In this code we have to find the error in the code implementation in which array is initialized and…
Q: The Fibonacci numbers begin with 1 and 1 and have the property that each subsequent number is the…
A: Answer: Code in java:- class Fibonacci { public static void main(String[] args) { int n = 100,…
Q: Seatwork BUG BUSTER: What is wrong with the following code fragment? int x,y; int array[10][3];…
A: Introduction: Here we are required to explain what is the problem with the given source code. OUTPUT…
Q: Write a definition statement for a character array large enough to hold any of the following strings:…
A: Given: Write a definition statement for a character array large enough to hold any of the following…
Q: public boolean move(int x, int y, int destX, int destY){ // TODO write this method…
A: public boolean freeWayHorizontally(int xO, int yO, int xD) { //RIGHT if (xO < xD) {…
Q: Design an intelligent number editor system, a menu driven application having following methods. Is…
A: #include <iostream>#include <array>using namespace std; #define MAX 100 int main(){…
Q: Use Java programming language Write a program that asks the user to enter 5 test grades (use an…
A: Note:Complete program is provided with all the required methods.Comments are provided for better…
Q: Generate six random numbers between 1 and 40, and keep them in one array. Sum the six numbers of the…
A: Ans: Code: import java.util.*;public class Main{ public static void main(String[] args) { Random…
Q: Write a method that rotates N number of 2-D points by given angle (counter-clockwise). The points…
A: The formula to rotate a point by a given angle is :
Q: In a game of tic-tac-toe, two players take turns marking an available cell in a 3x3 grid with their…
A: Given: In a game of tic-tac-toe, two players take turns marking an available cell in a 3x3 grid…
Q: Using java language In voltTest[10] is an encapsulated array that contains 10 voltages. Display how…
A: Testers - voltArray: int[0...9] - voltActive: int - voltSaturated : int - voltCutoff: int +…
Q: Call method "calculateUpperSectionCategory"
A: When method call is executed, control jumps to method definition and executes statements within it.…
Q: Question 18 D The following question uses a robot in a grid of squares. The robot is represented as…
A: The following code segment moves the robot around the grid. Assume that n is a positive integer.…
Q: an intelligent number editor system, a menu driven application having following methods. The…
A: It is defined as a direct descendant of C programming language with additional features such as type…
Q: convert this code to JAVA location = [] size = [] rover = 0 def displayInitialList(location,…
A: Dear Student,There were details missing in the code like The methods allocateMemory() and…
Q: The tetrahedron is a pyramid with a triangular base and three sides. Tetrahedral number is the…
A: Algorithm - Create a method tetra with one argument. Now create a nested loop. Use the below…
Q: age/plot an gif to this code. This is a brownian motion python code here it is code import numpy…
A: It is defined as a powerful general-purpose programming language. It is used in web development,…
Q: double diameter =2- radius;
A: public class DebugFour2{ public static void main(String args[]){ //start main method where program…
Q: is representing juicy Given a 2D array of watermelon where watermelon while 1 is representing seed,…
A: Start Since, Mubashir eats only 1/4th of watermelon each time, we would divide rows and columns by 2…
Q: An array currently contains 14 items, and its load factor is 0.70. What is its physical capacity?
A: ANSWER Formula to find physical capacity => Physical Capacity = Logical Size/Load factor
Q: Random walk. A Java programmer begins walking aimlessly. At each time step, she takes one step in a…
A: import java.util.Random; public class MyRandomWalker{ public static void main(String[] args) { //…
Q: Challenge: How many candy types are in the array? We want to know how many candy types we have in…
A: Its just a one line function. I have written comments in the code to explain what it does.
Q: Application of Linear Algebra in Computer Games Write a Python game(not too long and not too…
A: We have to write the code for any computer game in Python (not very long not very short, not too…
Q: Geometry: area of a pentagon) Write a program that prompts the user to enter the length from the…
A: Declare double type variables to store side and area of pentagon. Read distance from centre to…
Step by step
Solved in 3 steps
- mport java.util.Scanner; public class ParkingCharges { // function to calculate the basic charge using the asked hours static double getBasicCharge(int hours) { if (hours >= 7 && hours <= 8) return 5.50; else if (hours >= 5 && hours <= 6) return 4.50; else if (hours >= 2 && hours <= 4) return 4.00; return 3.00; } // function to return the amount to subtract based on local living and OAP static double getDiscount(String isLocal, String isOAP) { if (isOAP.equals("Yes") && isLocal.equals("Yes")) return 2.0 + 1.0; else if (isOAP.equals("Yes")) return 2.0; else if (isLocal.equals("Yes")) return 1.0; return 0; } public static void main(String[] args) { // create a new Scanner object Scanner sc = new Scanner(System.in); // prompt the user to ask if they are disabled…Problem Description: The international standard letter/number mapping found on the telephone keypad is shown below: Write a pseudocode and program that reads a letter and displays its corresponding digit. 2 3 1 ABC DEF 4 5 6 GHI JKL MNO 7 8 9 PQRS TUV WXYZ 0 Write a pseudocode on how you would solve the problem in your own word. Write a java program called Phone considering the following directions. Practice here first then write answer on the answer sheet. Also, make sure distinguish high and low caps as Java is case – sensitive. Import and declare a Scanner class Ask user for an Upper – case letter Use the switch statement along with case and break Use the System.exit(1) in the default to terminate the program Print the corresponding digitBulgarian solitaire def bulgarian_solitaire(piles, k): You are given a row of piles of pebbles, all identical, and a positive integer k so that the total number of pebbles in these piles equals k*(k+1)//2, the arithmetic sum formula that equals the sum of positive integers from 1 to k. Almost as if intended as a metaphor for the bleak daily life behind the Iron Curtain, all pebbles are identical and you don't have any choice in your moves. Each move picks up one pebble from each pile (even if doing so makes that pile vanish), and creates a new pile from the resulting handful. For example, starting with[7, 4, 2, 1, 1], the first move turns this into [6, 3, 1, 5]. The next move turns that into [5, 2, 4, 4], which then turns into the five-pile configuration [4, 1, 3, 3, 4], and so on. This function should count how many moves are needed to convert the given initial piles into the goal state where each number from 1 to k appears as the size of exactly one pile, and return that count. These…
- Question Language: JAVA Keep Guessing Write a program that plays a number-guessing game to guess a secret number randomly generated within the range 1 and 10. The user will get as many numbers of tries as he/she needs to guess the number. Tell the users if their guess is right or wrong and if their guess is wrong let them try to guess the number again. You must generate the secret number using the Java Random class. When the user guesses a number he/she will have to take an input of his guessed number from the keyboard. The user will have to take as many inputs as needed to guess the correct secret-number. That means the code will keep looping as long as the guess is different from the secret number. Use a while loop to prompt the user to guess again if the guess is wrong. Create a class named NumberGuessingGame which will contain the main method, write all your code in the main method. Sample input and output: Suppose the random number generated is 6. I have chosen a…Java Questions - (Has 2 Parts). Based on each code, which answer out of the choices "A,B,C,D,E" is correct. Each question has one correct answer. Thank you. Part 1 - 9. Given the following code, the output is the date and time of __.Calendar cal = Calendar.getInstance(); TimeZone tz = TimeZone.getTimeZone("Europe/Rome");TimeZone tz = TimeZone.getTimeZone("America/Los_Angeles");TimeZone tz = TimeZone.getTimeZone("Asia/Istanbul");System.out.println(cal.getTime()); A. the "Europe/Rome" time zone.B. the time zone is computer is currently set to use.C. the "America/Los_Angeles" time zone.D. the "Asia/Istanbul" time zone.E. All of the three listed time zones. Part 2 - 10. Given the following code, the output is the date and time of __. Calendar cal = Calendar.getInstance();TimeZone tz = TimeZone.getTimeZone("Europe/Rome");cal.setTimeZone(TimeZone.getTimeZone("America/Los_Angeles"));TimeZone tz = TimeZone.getTimeZone("Asia/Istanbul");System.out.println(cal.getTime()); A. the "Europe/Rome"…JAVA LANGUAGE Body Mass Index Version 2.0 by CodeChum Admin Recall that according to the National Heart, Lung, and Blood Institute of the National Institutes of Health, body mass index (BMI) is a measure of body fat based on height and weight that applies to adult men and women. It is used to monitor one's health by determining whether one is underweight, overweight, has normal weight or is obese. It is computed based as follows (when using standard weight in pounds and height in inches): BMI = 703 x (weight/(height2)) Furthermore, people with BMI scores that are less than 18.5 are said to be underweight. Those with scores between 18.5–24.9 (inclusive) are of normal weight. Those with scores between 25–29.9 (inclusive) are said to be overweight. And those with scores 30 or higher are obese. Input The input is composed of two positive integers representing the weight in pounds and the height in inches. 140·65 Output A single line containing two values: the computed…
- (Java) The greatest common divisor of two positive whole numbers and n1 and n2 is the largest number g such that g evenly divided into both n1 and n2. Write a complete program that takes two positive whole numbers from the user and displays the common divisor.Order check Write a program OrderCheck.java that takes four int command-line arguments w, x, y, and z. Define a boolean variable whose value is true if the four values are either in strictly ascending order (w < x < y < z) or strictly descending order (w > x > y > z), and false otherwise. Then, display the boolean variable value.In C++ class rectangleType { public: void setLengthWidth(double x, double y); //Sets the length = x; width = y; void print() const; //Output length and width double area(); //Calculate and return the area of the rectangle (length*width) double perimeter(); //Calculate and return the perimeter (length of outside boundary of the rectangle) private: double length; double width; }; Set the length of the rectangle to 24 and the width to 30.
- Java Questions - (Has 2 Parts). Based on each code, which answer out of the choices "A, B, C, D, E" is correct. Each question has one correct answer. Thank you. Part 1 - 9. In Java, composition is said to use __ relationship. A. is-aB. part-ofC. has-aD. both is-a and part-ofE. both has-a and part-of Part 2 - 10. Given the following code, which statement is true? class Water() { ... }class Juice() extends Water { ... }class Apple() { ... }class ApplePie() { Apple a1 = new Apple(); }class AppleJuice() { Apple a1 = new Apple(); Water w1 = newWater(); } A. Juice is a superclass and Water is a subclass.B. ApplePie is a superclass of Apple.C. ApplePie is a composite class that contains an instance of Apple class.D. AppleJuice is a superclass that contains an instance of Apple class and an instance of Water.E. Water is a composite class that contains an instance of Juice.HangmanAA.java For this program, you will create the game Hangman. (If you are unsure of how to play Hangman, Google it.) The game will start by asking player 1 for a word or phrase (can be multiple words). Then player 1 will be asked how many missed guesses are allowed by player 2. Once this information is received, player 2 will take over. (Have the program print many blank lines of space so that player 2 can’t see what player 1 entered.) The instructions should be displayed for player 2 as well as the number of misses they’re allowed to make before they lose the game. The screen should also output dashes or underscores to represent each letter of player 1’s secret word/phrase. Player 2 should guess one letter at a time. Case should not matter. Typing x or X should give the same result. If that letter is present in the mystery phrase, then it should be displayed. (It will replace the dash/underscore in that spot. Spaces, punctuation, and all other non-alphabetic characters should…Project Name: ActivitiesClass name: Dollar_Conversion Write a Java program that will accept theamount of US Dollar and convert to PhilippinePeso. The current exchange rate is 1 dollar is to 49.75pesos. Convert 50 dollars to peso. Display the converted value using three (3)decimal places. Using blueJ