Java How To Program (Early Objects)
10th Edition
ISBN: 9780133807943
Author: Deitel, Paul
Publisher: Pearson Education
expand_more
expand_more
format_list_bulleted
Question
Chapter 6, Problem 2MD
Program Plan Intro
Multiplication
Program Plan:
Multiply.java:
- Import required packages.
- Declare the class “Multiply”.
- Create an object for “random()”.
- Declare the variable “crtAns”.
- Define the main method.
- Create an object for scanner class.
- Declare the variable “guessVal”.
- Call the method “Question()”.
- Get the guess number from the user.
- Check whether the “guessVal” is not equal to “-1”.
- Call the method “Response()”.
- Get the guess value from the user.
- Definition of method “Question()”.
- Get the two random numbers between 0 and 10.
- Multiply the two numbers.
- Print the two numbers.
- Definition of method “printResponse()”.
- Check the condition is “true”.
- For correct guess, give the corresponding case option.
- For incorrect guess, give the corresponding case option.
- Definition of method “Response()”.
- Check whether the “guess” is not equal to “crtAns”
- Call the method “printResponse()”.
- Otherwise, call the method “printResponse()”.
- Call the method “Question()”.
- Check whether the “guess” is not equal to “crtAns”
SampleTest.java:
- Definition of class “SampleTest”.
- Definition of main method.
- Create an object for “Multiply” class.
- Call the method “quiz()”.
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
Complete the following sentence.
There are two basic forms of loop constructs: while loops and
loops.
Can u solve this ?
(python)
Write the program based on the details in the picture and the additional details below.
Since this is a simulation, we will not prompt the user for inputs. Any inputs will result in a loss of points. To determine the radius of the circle, add together your Birth Month and Day. So my radius would be 41.
NOTE: this radius will be used for all of the simulation trials.
Once you have the radius, implement the Monte Carlo simulation with 500,000 random (x,y) points (remember to make them floats) and display the results of 10 trials. Each trial does another simulation of 500,000 random (x,y).
Display the following for each trial:
Trial number
Number of hits inside the circle from the simulation
The percentage of hits (Only want 2 decimal places)
At the end you must display the average percentage for all 10 trials.
Bonus Option:
Create an 11th trial and create a graphic representation of the simulation.
Draw a square and corresponding circle (you do not need the grid)
Draw each…
Chapter 6 Solutions
Java How To Program (Early Objects)
Ch. 6 - A method is invoked with a(n)Ch. 6 - Prob. 1.2SRECh. 6 - Prob. 1.3SRECh. 6 - The keywordindicates that a method does not return...Ch. 6 - Prob. 1.5SRECh. 6 - Prob. 1.6SRECh. 6 - Prob. 1.7SRECh. 6 - An object of classproduces truly random numbers.Ch. 6 - Prob. 1.9SRECh. 6 - Prob. 1.10SRE
Ch. 6 - Prob. 1.11SRECh. 6 - Prob. 1.12SRECh. 6 - For the class Craps in Fig. 6.8, state the scope...Ch. 6 - the variable die1.Ch. 6 - the method rollDice.Ch. 6 - Prob. 2.4SRECh. 6 - Prob. 2.5SRECh. 6 - Write an application that tests whether the...Ch. 6 - Prob. 4.1SRECh. 6 - Method smallest, which takes three integers x, y...Ch. 6 - Prob. 4.3SRECh. 6 - Method intToFloat, which takes integer argument...Ch. 6 - Find the error in each of the following program...Ch. 6 - 1 int sum(int x, int y) { 2 int result; 3 result =...Ch. 6 - 1 void f(float a); { 2 float a; 3...Ch. 6 - 1 void product() { 2int, a = 6; 3int b = 5; 4int c...Ch. 6 - Declare method sphereVolume to calculate and...Ch. 6 - What is the value of x after each of the following...Ch. 6 - What is the value of x after each of the following...Ch. 6 - What is the value of x after each of the following...Ch. 6 - What is the value of x after each of the following...Ch. 6 - What is the value of x after each of the following...Ch. 6 - What is the value of x after each of the following...Ch. 6 - What is the value of x after each of the following...Ch. 6 - (Parking Charges) A parking garage charges a 2.00...Ch. 6 - (Rounding Numbers) Math.floor can be used to round...Ch. 6 - To round numbers to specific decimal places, use a...Ch. 6 - Prob. 5.1ECh. 6 - Write statements that assign random integers to...Ch. 6 - Write statements that will display a random number...Ch. 6 - (Exponentiation) Write a method integer Power...Ch. 6 - Define a method hypotenuse that calculates the...Ch. 6 - Prob. 10.1ECh. 6 - Prob. 11.1ECh. 6 - (Displaying a Square of Asterisks) Write a method...Ch. 6 - (Displaying a Square of Any Character) Modify the...Ch. 6 - Prob. 14.1ECh. 6 - (Separating Digits) Write methods that accomplish...Ch. 6 - (Separating Digits) Write methods that accomplish...Ch. 6 - Prob. 15.3ECh. 6 - (Temperature Conversions) Implement the following...Ch. 6 - Method fahrenheit returns the Fahrenheit...Ch. 6 - Prob. 16.3ECh. 6 - (Find the Minimum) Write a method minimum3 that...Ch. 6 - Prob. 18.1ECh. 6 - (Prime Numbers) A positive integer is prime if its...Ch. 6 - Prob. 20.1ECh. 6 - (Greatest Common Divisor) The greatest common...Ch. 6 - Write a method qualityPoints that inputs a...Ch. 6 - Write an application that simulates coin tossing....Ch. 6 - (Guess the Number) Write an application that plays...Ch. 6 - Prob. 25.1ECh. 6 - Prob. 26.1ECh. 6 - (Craps Game Modification) Modify the craps program...Ch. 6 - (Table of Binary, Octal and Hexadecimal Numbers)...Ch. 6 - (Computer-Assisted Instruction) The use of...Ch. 6 - Prob. 2MDCh. 6 - Prob. 3MDCh. 6 - (Computer-Assisted Instruction: Difficulty Levels)...
Knowledge Booster
Similar questions
- The use of computers in education is referred to as computer-assisted instruction (CAI). One problem that develops in CAI environments is student fatigue. This problem can be eliminated by varying the computer's dialogue to hold the student's attention. Modify the program in Exercise 9.22 to print one of a variety of comments for each correct answer and each incorrect an- swer. The set of responses for correct answers is as follows: Very good! Excellent! Nice work! Keep up the good work! The set of responses for incorrect answers is as follows: No. Please try again. Wrong. Try once more. Don't give up!No. Keep trying. Use random number generation to choose a number from 1 to 4 that will be used to select an appropriate response to each answer. Use a switch statement to issue the responses.arrow_forwardkindly change the program following the procedure on the problem. please list the changes you have made on the program t..thank youarrow_forwardImplement programs involving the use of while, do..while and for loop statement. Objectives: Topics Covered: Implementing programs using loops. Description FRIDAY THE 13TH When will Friday the 13th occur in 1990? Write a program that will find all months in 1990 in which the 13th falls on a Friday. You need to know the following. 1. January 1, 1990 was on a Monday. 2. September, April, June, and November have thirty days, all the rest have 31 except for February which has 28 except in leap years when it has 29. 3. 1990 is not a leap year. Note: To make it fair for everyone, you may not use any built-in date functions from your computer language. Sample Output if Applicable Sample Run In 1990, Friday the 13th occurs in the months: APRILarrow_forward
- (Learning Objective: students will be able to apply their knowledge of the built-in random package to generate simulations of simple phenomena.) Write a function: • dicesim(D1,D2,trials) that takes as input the number of sides on die 1 (D1) and die2 (D2) and the number of trials. Your function should repeatedly sum pairs of random numbers between 1 and D1 and 1 and D2 and keep track of how many times each sum occurs. The function returns a numpy array with the fraction each sum of rolls occured. Since the numbers are chosen at random, the fractions will differ some from run to run. One run of the function print(p22.dicesim(6,6,10000)) resulted in: [0. 0. 0.0259 0.0615 0.0791 0.1086 0.139 0.1633 0.1385 0.114 0.0833 0.0587 0.0281] or displayed using the code from Section 16.1.1.: PMF of X Note: you should submit a file with only the standard comments at the top and the function. The grading scripts will then import the file for testing.arrow_forwardANSWER IN PYTHON. THIS IS A CODING PROBLEM.arrow_forward(YOU ARE NOT ALLOWED TO USE ARRAYLIST IN THIS PROJECT)Write a Java program to simulate a blackjack game of cards. The computer will play the role of the dealer. The program will randomly generate the cards dealt to the player and dealer during the game. Cards in this game will be represented by numbers 1 to 13 with Ace being represented by a 1. Remember, that face cards (i.e. Jack, Queen, and King) are worth 10 points to a hand while an Ace can be worth 1 or 11 points depending on the user’s choice. The numbered cards are worth their number value to the hand.arrow_forward
- Use java language to code this.arrow_forward(Consider the structure that the code must have. It is shown at the end of the task and the code must have the same structure)arrow_forwardodify the guessing-game program so that the user thinks of a number that the computer must guess. The computer must make no more than the minimum number of guesses, and it must prevent the user from cheating by entering misleading hints. Use I'm out of guesses, and you cheated and Hooray, I've got it in X tries as your final output. (Hint: Use the math.log function to compute the minimum number of guesses needed after the lower and upper bounds are entered.) this is what I got so far: ============================================ import random import math smaller = int(input("Enter the smaller number: ")) larger = int(input("Enter the larger number: ")) maxattempt = math.ceil(math.log(larger - smaller)) count = 0 while count != maxattempt: count += 1 guess = int((smaller + larger) / 2) print(smaller, larger) print("Your number is: ", guess) hlp = input("Enter =, <, or >: ") if hlp == '>': smaller = guess + 1 elif hlp == '<':…arrow_forward
- python only** define the following function: This function must return the task status for a particular task from a checklist. These examples for taskStatus demonstrate how it works. As with addTask, there's the possibility that the task specified is invalid (in this case, because it isn't in the checklist). In that case, taskStatus must print a specific message ("That task does not exist."), and must return None. Define taskStatus with 2 parameters Use def to define taskStatus with 2 parameters Use a return statement Within the definition of taskStatus with 2 parameters, use return _ in at least one place. Do not use any kind of loop Within the definition of taskStatus with 2 parameters, do not use any kind of loop.arrow_forwardUnder your module imports, paste the following definitions: (define WIDTH 300) (define HEIGHT 160) (define ES (empty-scene WIDTH HEIGHT)) (define (next-size s) (/ s 2)) Next, write a tail-call recursive function called circles. This function should take two numbers, x and size, and a Scene scn. If size is less-than or equal to 2, then your function returns the scn unchanged (base case). Otherwise, your function should place a circle in the Scene that results from a recursive call to circles with x shifted by (+ size (next-size size)), a new size of (next-size size), and using the original Scene. After evaluating (circles 100 48 ES), your function should output this image of five blue circles, in this order, with the first circle at (x,y) coordinate position (100, 80):arrow_forwardanswer questions ( java language ) let: a= 2 b = 4 c= 5 d= 2 e= 20 f= 50arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- C++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage LearningC++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology Ptr
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning
C++ for Engineers and Scientists
Computer Science
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Course Technology Ptr