Java Programming (MindTap Course List)
9th Edition
ISBN: 9781337397070
Author: Joyce Farrell
Publisher: Cengage Learning
expand_more
expand_more
format_list_bulleted
Question
Chapter 4, Problem 7PE
Program Plan Intro
Math operations
Program plan:
Filename: “MathTest.java”
- Define the “MathTest” class
- Define the main method.
- Calculate the square root of 37 and display the value
- Calculate the sine 300 and display the result.
- Calculate the floor of 22.8 and display the result.
- Check “D” is greater than 71,
- Display “D” is larger. Otherwise, display 71 is larger.
- Display the random number between 0 and 20.
Expert Solution & Answer
Trending nowThis is a popular solution!
Students have asked these similar questions
Write a Java application that uses the Math class to determine theanswers for each of the following:
a. The square root of 30b. The sine and cosine of 100c. The value of the floor, ceiling, and round of 44.7d. The larger and the smaller of the character K and the integer 70e. A random number between 0 and 10 (Hint: The random() method returns a value between 0 and 1; you want a number that is 10 times larger.)Save the application as MathTest.java
6. Write a method that reads three strings from the keyboard. Although the strings are in no particular order, display the string that would be second if they were arranged lexicographically.
7. Write a method that reads a one-line sentence as input and then displays the following response: If the sentence ends with a question mark (?) and the input contains an even number of characters, display the word Yes. If the sentence ends with a question mark and the input contains an odd number of characters, display the word No. If the sentence ends with an exclamation point (!), display the word Wow. In all other cases, display the words You always say followed by the input string enclosed in quotes. Your output should all be on one line. Be sure to note that in the last case, your output must include quotation marks around the echoed input string. In all other cases, there are no quotes in the output. Your program does not have to check the input to see that the user has entered a…
In a C# Console App do the following
Write a method that takes three integers and returns true if their sum is divisible by 3, false otherwise.
Write a method that takes two strings and displays the string that has fewer characters.
Write a method that takes two bool variables and returns true if they have the same value, false otherwise.
Write a method that takes an int and a double and returns their product.
Chapter 4 Solutions
Java Programming (MindTap Course List)
Ch. 4 - Prob. 1RQCh. 4 - Prob. 2RQCh. 4 - Prob. 3RQCh. 4 - Prob. 4RQCh. 4 - Prob. 5RQCh. 4 - Prob. 6RQCh. 4 - Prob. 7RQCh. 4 - Prob. 8RQCh. 4 - Prob. 9RQCh. 4 - Prob. 10RQ
Ch. 4 - Prob. 11RQCh. 4 - Prob. 12RQCh. 4 - Prob. 13RQCh. 4 - Prob. 14RQCh. 4 - Prob. 15RQCh. 4 - Prob. 16RQCh. 4 - Prob. 17RQCh. 4 - Prob. 18RQCh. 4 - Prob. 19RQCh. 4 - Prob. 20RQCh. 4 - Prob. 1PECh. 4 - Prob. 2PECh. 4 - Prob. 3PECh. 4 - Prob. 4PECh. 4 - Prob. 5PECh. 4 - Prob. 6PECh. 4 - Prob. 7PECh. 4 - Prob. 8PECh. 4 - Prob. 9PECh. 4 - Prob. 10PECh. 4 - Prob. 11PECh. 4 - Prob. 1GZCh. 4 - Prob. 2GZ
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Similar questions
- Q1: Write a java program that includes a method called Reader that reads unlimited number from the users, then you have to determines the following: a. How many even values b. How many odd values c. Computes the total of the input values d. Computes the average of the of the input values e. The program should be ends with the input 0 (not counting zero as an input).arrow_forwardWrite an application that reads an integer and determines and prints whether it’s odd or even. [Hint: Use the remainder operator. An even number is a multiple of 2. Any multiple of 2 leaves a remainder of 0 when divided by 2.]arrow_forwardC# Part 1: In your program, write a method that accepts a positive integer and returns true if the number is a prime number and false otherwise. Note that 2 is the only even prime number. An odd integer is prime if it not divisible by any odd integer less than or equal to the square root of the number. Part2: A prime number whose reversal is also a prime number is called emirp. For example, 11, 13, 79 and 359 are emirps. Write a program that outputs to a ListBox the first 100 emirps. Your program must contain the method from Part 1 that returns true if a number is prime; false otherwise and another method that returns the reversal of a positive number. You can reverse the integer in the following way: • Convert the integer into a string value = num.ToString(); • Use the following code to reverse the integer string newNum = “”; for (int l = value.Length; l > 0; l--) newNum = newNum + value[l-1]; Also, your program should have a TextBox that will accept a positive integer from the…arrow_forward
- Java Code public static method named oddsarrow_forwardPlease help me! I have a lot of mini problems. I'm not sure how to start After #6, I have other problems. Those are : 7.) Write a method that reads a one-line sentence as input and then displays the following response: If the sentence ends with a question mark (?) and the input contains an even number of characters, display the word Yes. If the sentence ends with a question mark and the input contains an odd number of characters, display the word No. If the sentence ends with an exclamation point (!), display the word Wow. In all other cases, display the words You always say followed by the input string enclosed in quotes. Your output should all be on one line. Be sure to note that in the last case, your output must include quotation marks around the echoed input string. In all other cases, there are no quotes in the output. Your program does not have to check the input to see that the user has entered a legitimate sentence. Notes: This code requires a three-way selection statement and…arrow_forwardjava-Find the area of circle using method... Write an application that prompts the user for the radius of a circle and uses a method called circleArea to find tarea of the circle. method method should return the computed area to the caller method.arrow_forward
- in Java Tasks Write a program that lets the user play the game of Rock, Paper, Scissors against the computer. The program should work as follows. 1. When the program begins, a random number in the range of 1 through 3 is generated. If the number is 1, then the computer has chosen rock. If the number is 2, then the computer has chosen paper. If the number is 3, then the computer has chosen scissors. (Don't display the computer's choice yet.) 2. The user enters his or her choice of "rock", "paper", or "scissors" at the keyboard. (You can use a menu if you prefer.) 3. The computer's choice is displayed. Tasks 4. A winner is selected according to the following rules: a. If one player chooses rock and the other player chooses scissors, then rock wins. (The rock smashes the scissors.) b. If one player chooses scissors and the other player chooses paper, then scissors wins. (Scissors cuts paper.) C. If one player chooses paper and the other player chooses rock, then paper wins. (Paper wraps…arrow_forwardPrime number is the number that is divided by one and itself only, Twin Prime is a pair of prime numbers that differ by 2. For example, 3 and 5 are twin primes, 5 and 7 are twin primes, and 11 and 13 are twin primes. Write a java program to find all twin primes within a range of 1 up to a number entered by user, such that, that the entered number should be greater than 10. The program has to have a method that takes an integer as a formal parameter and returns if that number is prime or not. Display the output as follows: Enter an integer (greater than 10): 7 Not accepted number! Enter an integer (greater than 10): 50 The number of twin prime numbers up to 50 are: (3, 5) (5, 7) (11, 13) (17, 19) (29, 31) (41, 43)arrow_forwardThe area of a rectangle can be computed using the following formula: area = width * height; Write a method that returns the area of a rectangle using the following header: public static double getArea(double width, double height) Write a main method that prompts the user to enter the width and height of a rectangle and displays its area. Input example: 1.2 3.4 Output example: The area of the rectangle is 4.08arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Programming Logic & Design ComprehensiveComputer ScienceISBN:9781337669405Author:FARRELLPublisher:Cengage
Programming Logic & Design Comprehensive
Computer Science
ISBN:9781337669405
Author:FARRELL
Publisher:Cengage
Java random numbers; Author: Bro code;https://www.youtube.com/watch?v=VMZLPl16P5c;License: Standard YouTube License, CC-BY