Introduction to Java Programming and Data Structures, Comprehensive Version (11th Edition)
11th Edition
ISBN: 9780134670942
Author: Y. Daniel Liang
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Question
Chapter 3.7, Problem 3.7.1CP
Program Plan Intro
Math.random():
- It is a function that is used to generate random numbers from the range 0 to 1, including 0 but not 1.
- This function also gets the floating point numbers from the range 0 and 1.
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
Q3/ Answer with true or false for any three of the following, ( enhance your answer with interpretation).
1: The EraseMode method is better than the Movie method.
2: The ode45function represents the Euler's method.
3: The instruction Rand(n,0) gives random number between 0 and n.
4: In the Movie method there is no need for a pause.
Write an application that reads an integer value from the user and prints the sum ofall even integers between 2 and the input value, inclusive. Print an error message ifthe input value is less than 2. Use Java. Sample Run Examples:
Example 1:the user enters 14Output: Sum: 56Example 2:the user enters 1Output: Error number must be greater than 1
Generate a list of 10 random numbers with values between 1 and 20, and submit the first 10 numbers as an answer to this question. (Use any random number generator). For the purpose of using them in the next questions, call these numbers A, B, C, D, . . . J
Convert Aπ/B into degrees.
Find the result ofa. Degrees = (A × B × C) + 180 mod 180; this is the remainder after dividing (A × B × C) + 180 by 180
b. Convert Degrees into radians, and put the answer in π notation.
Calculate the measurements of the acute angles of a right triangle whose sides measure A, B, C units.
Build a matrix, M, of random numbers as follows:
A
B
C
D
E
F
G
H
I
What is MT?
Find the inverse of M, showing the steps.
What is the result of M * M−1?
Let V = [A B C] and W = [ D E F]. In the textbook, the dot product V • W involves an angle, alpha (α). How do you calculate alpha for this example?
Let V = [A B C]. Find the cross product V • V. What can you conclude from this…
Chapter 3 Solutions
Introduction to Java Programming and Data Structures, Comprehensive Version (11th Edition)
Ch. 3.2 - List six relational operators.Ch. 3.2 - Assuming x is 1, show the result of the following...Ch. 3.2 - Can the following conversions involving casting be...Ch. 3.3 - Write an if statement that assigns 1 to x if y is...Ch. 3.3 - Write an if statement that increases pay by 3% if...Ch. 3.3 - Prob. 3.3.3CPCh. 3.4 - Write an if statement that increases pay by 3% if...Ch. 3.4 - What is the output of the code in (a) and (b) if...Ch. 3.5 - Prob. 3.5.1CPCh. 3.5 - Suppose x = 2andy = 3. Show the output, if any, of...
Ch. 3.5 - What is wrong in the following code? if (score =...Ch. 3.6 - Which of the following statements are equivalent?...Ch. 3.6 - Prob. 3.6.2CPCh. 3.6 - Are the following statements correct? Which one is...Ch. 3.6 - Prob. 3.6.4CPCh. 3.7 - Prob. 3.7.1CPCh. 3.7 - a. How do you generate a random integer i such...Ch. 3.9 - Are the following two statements equivalent?Ch. 3.10 - Assuming that x is 1, show the result of the...Ch. 3.10 - (a) Write a Boolean expression that evaluates to...Ch. 3.10 - (a) Write a Boolean expression for |x 5| 4.5....Ch. 3.10 - Assume x and y are int type. Which of the...Ch. 3.10 - Are the following two expressions the same? (a) x...Ch. 3.10 - What is the value of the expression x = 50 x =...Ch. 3.10 - Suppose, when you run the following program, you...Ch. 3.10 - Write a Boolean expression that evaluates to true...Ch. 3.10 - Write a Boolean expression that evaluates to true...Ch. 3.10 - Write a Boolean expression that evaluates to true...Ch. 3.10 - Write a Boolean expression that evaluates to true...Ch. 3.11 - Prob. 3.11.1CPCh. 3.12 - What happens if you enter an integer as 05?Ch. 3.13 - What data types are required for a switch...Ch. 3.13 - What is y after the following switch statement is...Ch. 3.13 - What is x after the following if-else statement is...Ch. 3.13 - Write a switch statement that displays Sunday,...Ch. 3.13 - Prob. 3.13.5CPCh. 3.14 - Suppose when you run the following program, you...Ch. 3.14 - Rewrite the following if statements using the...Ch. 3.14 - Rewrite the following codes using if-else...Ch. 3.14 - Write an expression using a conditional operator...Ch. 3.15 - List the precedence order of the Boolean...Ch. 3.15 - True or false? All the binary operators except =...Ch. 3.15 - Evaluate the following expressions: 2 2 3 2 4 ...Ch. 3.15 - Is (x 0 x 10) the same as ((x 0) (x 10))? Is...Ch. 3 - (Algebra: solve quadratic equations) The two roots...Ch. 3 - (Game: add three numbers) The program in Listing...Ch. 3 - (Algebra: solve 2 2 linear equations) A linear...Ch. 3 - (Random month) Write a program that randomly...Ch. 3 - (Find future dates) Write a program that prompts...Ch. 3 - (Health application: BMI) Revise Listing 3.4,...Ch. 3 - (Financial application: monetary units) Modify...Ch. 3 - Prob. 3.8PECh. 3 - (Business: check ISBN-10) An ISBN-10...Ch. 3 - (Game: addition quiz) Listing 3.3,...Ch. 3 - (Find the number of days in a month) Write a...Ch. 3 - (Palindrome integer) Write a program that prompts...Ch. 3 - (Financial application: compute taxes) Listing...Ch. 3 - (Game: heads or tails) Write a program that lets...Ch. 3 - (Game: lottery) Revise Listing 3.8, Lottery.java....Ch. 3 - Prob. 3.16PECh. 3 - (Game: scissor, rock, paper) Write a program that...Ch. 3 - (Cost of shipping) A shipping company uses the...Ch. 3 - (Compute the perimeter of a triangle) Write a...Ch. 3 - (Science: wind-chill temperature) Programming...Ch. 3 - Prob. 3.21PECh. 3 - (Geometry: point in a circle?) Write a program...Ch. 3 - (Geometry: point in a rectangle?) Write a program...Ch. 3 - (Game: pick a card) Write a program that simulates...Ch. 3 - (Geometry: intersecting point) Two points on line...Ch. 3 - (Use the , ||, and ^ operators) Write a program...Ch. 3 - (Geometry: points in triangle?) Suppose a right...Ch. 3 - (Geometry: two rectangles) Write a program that...Ch. 3 - (Geometry: two circles) Write a program that...Ch. 3 - (Current time) Revise Programming Exercise 2.8 to...Ch. 3 - (Financials: currency exchange) Write a program...Ch. 3 - Prob. 3.32PECh. 3 - (Financial: compare costs) Suppose you shop for...Ch. 3 - Prob. 3.34PE
Knowledge Booster
Similar questions
- ) Write a Java method that prints integers from 1 to 100 (see the output). Use the following output as a guide:arrow_forwardUsing Math.max and/or Math.min, write a class MaxOrMin, and make sure touse Math.max and Math.min which does the following: a. Create a Scannerb. Declare two variables, number1 and number 2c. Ask the user to enter 2 numbersd. Using the information above, print messages displaying the highest and lowest values ora message if the numbers are equal. The messages should look like the sample outputbelow Tip• Use if-else statement Submission• Copy and paste your code• Screen shot the console with user input of three examples Sample Run Enter a number 5Enter a number 9The lowest value is 5The highest value is 9 Enter a number 24Enter a number 11The lowest value is 11The highest value is 24 Enter a number 12Enter a number 1212 and 12 are equalarrow_forward5. Write a Java method that prints integers from 1 to 100 (see the output). Use the following output as a guide: 5 2 12 22 32 42 52 62 72 82 92 Press any key to continue 3 13 23 33 43 53 63 73 83 93 4 ? 8 18 28 38 48 58 68 78 88 98 1 11 31 41 51 61 71 81 91 14 24 34 44 54 64 74 84 85 94 15 25 35 45 55 65 75 26 36 46 56 66 76 86 96 37 47 57 67 ?? 87 97 19 29 39 49 59 69 79 89 99 10 20 30 40 50 60 70 80 90 100 95 123456780 6669 H23 456arrow_forward
- Write java program that generate two integer random numbers between 15 and 43 and print out the result of four operations between the two numbers, addition, subtraction, multiplication, division. The program must have the following methods: 1- Method to generate a random number and return it. 2- Method for addition operation accept two numbers and return back the result of addition operation. 3- Method for subtraction operation accept two numbers and rețurn back the result of subtraction operation. 4- Method for multiplication operation accept two numbers and return back the result of multiplication operation. 5- Method for division operation accept two numbers and return back the result of division operation. 6- Method to display the operation result which accept a string and three numbers. 7- Main method to run the program by calling the above methods. bmission instructions:arrow_forwardWrite java program that generate two integer random numbers between 15 and 43 and printout the result of four operations between the two numbers, addition, subtraction,multiplication, division.The program must have the following methods:1- Method to generate a random number and return it.2- Method for addition operation accept two numbers and return back the result ofaddition operation.3- Method for subtraction operation accept two numbers and return back the result ofsubtraction operation.4- Method for multiplication operation accept two numbers and return back the result ofmultiplication operation.5- Method for division operation accept two numbers and return back the result of divisionoperation.6- Method to display the operation result which accept a string and three numbers.7- Main method to run the program by calling the above methods.arrow_forward: In the classic problem FizzBuzz, you are told to print the numbers from 1 to n. However,when the number is divisible by 3, print "Fizz''. When it is divisible by 5, print "Buzz''. When it isdivisible by 3 and 5, print"FizzBuzz''. In this problem, you are asked to do this in a multithreaded way.Implement a multithreaded version of FizzBuzz with four threads. One thread checks for divisibilityof 3 and prints"Fizz''. Another thread is responsible for divisibility of 5 and prints"Buzz''. A third threadis responsible for divisibility of 3 and 5 and prints "FizzBuzz''. A fourth thread does the numbers.arrow_forward
- Write a java program named ReverseNumbers that prompts the user to enter 10 numbers, then prints the numbers in reverse order: Enter 10 numbers: 34, 82, 49, 102, 7, 94, 23, 11, 50, 31 In reverse order: 31, 50, 11, 23, 94, 7, 102, 49, 82, 34arrow_forwardProgramming language: JAVA: Processing Exercise 2. In section 7.3, you made a ball orbit the mouse. Make the ball orbit in an ellipse instead of a circle. You can do this by using a different radius for the x and for the y calculations. Make multiple balls orbit the mouse at different speeds. E.g., make three. Make one move in the opposite direction (counter-clockwise). Example in 7.3 codes attached with a photo. Cannot use advanced coding! we have only learned active processing, user defined functions, float, simple trig so fararrow_forwardGenerate 5000 random numbers in the range of [-16 to +16] both values are inclusive. Find and print the average of all of these 5000 random numbers. Importing classes from Java API. Instantiation: Making objects from Classes Random is another class in “java.util” package used for generating random numbers in various forms. Randomness has many uses and applications in science, art, statistics, cryptography, gaming, and other fields. For example, random numbers helps scientists to test hypotheses. Random numbers also have a lot of applications in video games production and other simulation fields. Again the “new” operator can be used to create an instance (object-ref) of this class. In other words, by using the “new” operator with the constructor method, you can create a new object-Ref of this class and then through the object-Ref we can call the methods defined in the Random class. Random myRand = new Random(); Among the many methods defined in the Random class, few…arrow_forward
- Question 16 What is output by the code below? for x in range(4): print(x, end = 0 4 O 4 4 4 4 01 2 3 O 0 1 2 3 0 1 2 3 4arrow_forwardcreate a java application that: Prompts the user for a number called num (MUST BE INTEGER). Finds if num is odd or even. if the num is even, Outputs:- num is an EVEN number. - Result of (num * 3) If the num is odd, Outputs: - num is an ODD number. - Result of (num / 2)arrow_forwardcan you add a screenshot showing that you are writing and running the code in Matlab/Octave.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