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
DO NOT USE EXISTING ANSWERS ON CHEGG OR COURSE HERO OR ANY OTHER SERVICES PLEASE! Thanks :)
CODE IN PYTHON AND SHOW COMMENTS TO EXPLAIN CODE
A confused Dutchman trying to speak English could say “I am in the war”, even though there is no hostile activity going on. The confusion1 here is that the English sentence “I am confused” is translated in Dutch as “Ik ben in de war”, which is phonetically (“sounding”) quite close to the first sentence. Such confusion leads to much enjoyment, but can complicate matters a bit.
Given a sentence in Dutch and a dictionary containing both correct translations as well as phonetic (incorrect) translations of individual words, find the translation of the sentence and indicate whether it is correct, or in case there is more than one find the total number of correct and incorrect translations. A sentence is correctly translated when each word of the sentence is correctly translated.
Input
The input consists of:
One line with an integer n (1≤n≤20), the…
RECURSION 1
Good day please help me with this practice exercise for our upcoming exam on last week of january.. I promise to give helpful rating after.
Note:
Please give the output of the program in the picture
Please write your answer on a PAPER the tracing of the program in the picture. The answer should explain step by step on how I will get the output.
Please refer to the second photo a sample tracing on how you would trace the first picture..
AGAIN 2ND PHOTO IS ONLY A SAMPLE ON HOW TO TRACE THE PROGRAM.
(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
- Pythonarrow_forwardDo not use static variables to implement recursive methods. USING JAVA 1. Using Big Oh notation, indicate the time requirement for each of the following tasks in the worst case. Describe which operations are assumed to take constant time to. After arriving at a party, you shake hands with each person there. n is the number of persons in the party. Each person in a room shakes hands with everyone else in the room. n is the number of persons in the room. You climb a flight of stairs. n is the number of stairs After entering an elevator, you press a button to choose a floor. n is the number of floors You ride the elevator from the ground floor up to the nth floor. You read a book twice. n is the number of pages in the book Using Big Oh notation, indicate the time requirement of each of the following tasks in the worst case. Display all the integers in an array of integers. Display all the integers in a chain of linked nodes. Display the nth integer in an array of integers. Compute…arrow_forwardTask #1 Tracing Recursive Methods 1. Copy the file Recursion.java (see Code Listing 16.1) from the Student Files or as directed by your instructor. 2. Run the program to confirm that the generated answer is correct. Modify the factorial method in the following ways: a. Add these lines above the first if statement: int temp; System.out.println ("Method call "calculating "Factorial of: " + n); Copyright © 2019 Pearson Education, Inc., Hoboken NJ b. Remove this line in the recursive section at the end of the method: return (factorial(n - 1) * n); c. Add these lines in the recursive section: temp - factorial (n - 1) ; System.out.println ("Factorial of: " + (n - 1) + " is " + temp); return (temp * n); 3. Rerun the program and note how the recursive calls are built up on the run-time stack and then the values are calculated in reverse order as the run-time stack "unwinds".arrow_forward
- 1) Simple Calculator: In Python, implement a simple calculator that does the following operations: summation, subtraction, multiplication, division, sqrt, power, natural log and abs. a) Follow the instructions below: To work with the calculator, the user is asked to enter the first number, then the operation, and finally, a second number if required. Your code has to recognize the need for the second number and ask for it if required. After performing one operation, the calculator prints the output of the operation. After performing one operation, the calculator must not exit. It has to start again for the next operation. The calculator will be closed if the user writes 'e' as any input. Use functions to perform the operations and the appropriate conditions to prevent common errors such as entering characters as one of the numbers etc. b) Run your code and provide the results for at least one example per operation. - -arrow_forwardLoops summary: for vs. while We have now seen that Python has two different loop constructs: the for loop and the while loop. The while loop is more powerful than the for loop, since it can be used in situations where the number of iterations isn't known in advance. For example, the following while loop answers the question: "If a population of bacteria increases in size by 21% every minute, how long does it take for the population size to double?" minutes = 0 population = 1000 growth_rate = 0.21 while population < 2000: population *= (1 + growth_rate) minutes += 1 print (f"{minutes} minutes required.") print (f"Population = {int(population)}") This would not be well suited to a for loop - we are trying to find out how many times the loop will run, and a for loop expects to know how many times it will run before it starts. In contrast, the for loop is a special case of the more general while loop, meaning that any program written with for loops can be rewritten to use while loops.…arrow_forwardANSWER IN PYTHON PLEASE.arrow_forward
- Object-Oriented Programming ------------------------------------arrow_forwardflow chart and dimple program. Python thank youarrow_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
- (using recursive function) Write programs that implement the following equations п Σ Y = 7K k=0 **please answer quicklyarrow_forward4. The Area of the Target: To decide on prizes for the archery contest, you decided to use the areas of the center and rings. You decided that rings with smaller areas should be worth more points. But how much more? Complete the following investigation to help you decide. a. Find the sequence of the areas of the rings, including the center. (Be careful.) b. Write a recursive formula and an explicit formula for this sequence. C. Write the explicit formula in summation notation. Find the total area of the bull's eye if it had 9 rings around the bull's eye.arrow_forwardCorrect answer will be upvoted else Multiple Downvoted. Don't submit random answer. Computer science. anglers have recently gotten back from a fishing excursion. The I-th angler has gotten a fish of weight man-made intelligence. Anglers will flaunt the fish they got to one another. To do as such, they initially pick a request where they show their fish (every angler shows his fish precisely once, in this way, officially, the request for showing fish is a stage of integers from 1 to n). Then, at that point, they show the fish they discovered by the picked request. At the point when an angler shows his fish, he may either become glad, become dismal, or stay content. Assume an angler shows a fish of weight x, and the most extreme load of a formerly shown fish is y (y=0 if that angler is quick to show his fish). Then, at that point: in the event that x≥2y, the angler becomes cheerful; in the event that 2x≤y, the angler becomes miserable; in the event that none of these two…arrow_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