Introduction to Java Programming and Data Structures Comprehensive Version (11th Edition)
11th Edition
ISBN: 9780134700144
Author: 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.
in java
Use scnr.nextInt() to read integers from input into inputData until 1000 is read. For each remaining integer read before 1000, if the integer is non-positive, output the integer followed by a newline and add the integer to sumOfSelected.
Ex: If the input is -23 13 -5 -4 -17 1000, then the output is:
-23 -5 -4 -17 The sum of all non-positive values is -49
Note: The sentinel value is 1000.
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
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
- Using 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_forwardQuestion 2: Take a lowercase word as an input from the user. Modify the word in such a way that the letters in the multiple of 3 positions become uppercase except position 0. Lastly, print the newly modified word. [You are not allowed to use upper() method] Sample Input1: jupyter Sample Output1: jupYteR Explanation 1: The characters 'y' and 'r' are in positions 3 and 6 respectively. So, these two characters will be converted to uppercase in the modified string. Sample Input2: python notebook Sample Output2: pytHon noTebOok Explanation 2: The characters 'h', 't', and 'o' are in positions 3, 9, and 12 respectively. So, these three characters will be converted to uppercase in the modified string.arrow_forward
- Programming 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_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_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
- 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 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 return 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.arrow_forwardWrite 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_forward
- Eclipse Java: Write a program that reads a string (password) and a number. The maximum number of attempts (3). The program with stop asking data if the word ‘quit’ is provided in the password valuearrow_forwardExercise 1Write a Java method random that generates and returns a random number between 14 and 59(using SecureRandom). Test your method several times using a main functionarrow_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_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