Introduction to Java Programming and Data Structures: Brief Version (11th Global Edition)
11th Edition
ISBN: 9780134671710
Author: Y. Daniel Liang
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Question
Chapter 4.2, Problem 4.2.7CP
Program Plan Intro
Mathematical functions:
- The “Math” class in the Java provides many useful methods for performing common mathematical functions.
- The “Math” class can be categorized as an exponent methods, trigonometric methods and service methods.
- The “Math” class also provides two “double” constants, “PI” and “E”.
Trigonometric method:
Trigonometric method consists of eight methods. They are:
- sin (randians) – it will return the sine of an angle in radians
- asin (a) – it will return the angle in radians for the inverse of sine
Exponent method:
Exponent methods consist of five methods. They are:
exp (x) – it will return “e” raised to power of “x”.
log (x) – it will return the natural logarithm of “x”
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
For each of the following program fragments:
Give an analysis of the running time (Big-Oh). Justify your answer?
A.
public class GFG {
// Linearly search x in att[]. if x is present then
//return the index, otherwise return -1
static int search (int arr[], int n, intx)
{
int i;
for (i = 0: i
2. Fill in the blanks for the number conversions:
(a) (110010101101)2=(
D16
(b) (A1FE)16=(
(c) (2020)10=(
D16=(
2=(
sum= 0;
for (int i = 0; i 1) {
sum++;
i= 1/2;
}
= 2*log2 (n)
We denote by Ta(n), Tb (n), Te(n) the running time of the three fragments.
1. Give evaluations for Ta(n), Tb (n), Te(n).
2. Is T(n) = O(Ta(n)) ? Answer YES or NO and justify your answer.
3. Is Te(n) = (Ta(n)) ? Answer YES or NO and justify your answer.
Chapter 4 Solutions
Introduction to Java Programming and Data Structures: Brief Version (11th Global Edition)
Ch. 4.2 - Evalute the following method calls: (a)...Ch. 4.2 - True or false? The argument for trigonometric...Ch. 4.2 - Write a statement that converts 47 degrees to...Ch. 4.2 - Write a statement that converts PI to an angle in...Ch. 4.2 - Write an expression that obtains a random integer...Ch. 4.2 - Prob. 4.2.6CPCh. 4.2 - Prob. 4.2.7CPCh. 4.3 - Use print statements to find out the ASCII code...Ch. 4.3 - Which of the following are correct literals for...Ch. 4.3 - How do you display the characters \ and "?
Ch. 4.3 - Evaluate the following: Int i = '1'; int j ='1' +...Ch. 4.3 - Can the following conversions involving casting be...Ch. 4.3 - Show the output of the following program: public...Ch. 4.3 - Write the code that generates a random lowercase...Ch. 4.3 - Show the output of the following statements:...Ch. 4.4 - Suppose s1, s2, and s3 are three strings, given as...Ch. 4.4 - Prob. 4.4.2CPCh. 4.4 - Show the output of the following statements (write...Ch. 4.4 - Prob. 4.4.4CPCh. 4.4 - Let s1 be " Welcome " and s2 be " welcome ". Write...Ch. 4.4 - Write one statement to return the number of digits...Ch. 4.4 - Write one statement to return the number of digits...Ch. 4.5 - If you run Listing 4.3 GuessBirthday.java with...Ch. 4.5 - If you enter a lowercase letter such as b, the...Ch. 4.5 - What would be wrong if lines 6 and 7 are in...Ch. 4.6 - Prob. 4.6.1CPCh. 4.6 - Prob. 4.6.2CPCh. 4.6 - Show the output of the following statements: (a)...Ch. 4 - (Geometry: area of a pentagon) Write a program...Ch. 4 - (Geometry: great circle distance) The great circle...Ch. 4 - (Geography: estimate areas) Use the GPS locations...Ch. 4 - (Geometry: area of a hexagon) The area of a...Ch. 4 - (Geometry: area of a regular polygon) A regular...Ch. 4 - (Random points on a circle) Write a program that...Ch. 4 - (Corner point coordinates) Suppose a pentagon is...Ch. 4 - (Find the character of an ASCII code) Write a...Ch. 4 - (Find the Unicode of a character) Write a program...Ch. 4 - (Guess birthday) Rewrite Listing 4.3,...Ch. 4 - (Decimal to hex) Write a program that prompts the...Ch. 4 - (Hex to binary) Write a program that prompts the...Ch. 4 - (Vowel or consonant?) Write a program that prompts...Ch. 4 - (Convert Letter grade to number) Write a program...Ch. 4 - (Phone key pads) The international standard...Ch. 4 - (Random character) Write a program that displays a...Ch. 4 - (Days of a month) Write a program that prompts the...Ch. 4 - (Student major and status) Write a program that...Ch. 4 - (Business: check ISBN-10) Rewrite Programming...Ch. 4 - (Process a string) Write a program that prompts...Ch. 4 - (Check SSN) Write a program that prompts the user...Ch. 4 - (Check substring) Write a program that prompts the...Ch. 4 - 23 (Financial application: payroll) Write a...Ch. 4 - (Order three cities) Write a program that prompts...Ch. 4 - (Generate vehicle plate numbers) Assume that a...Ch. 4 - (Financial application: monetary units) Rewrite...
Knowledge Booster
Similar questions
- int functionC (int n) { int i, j, sumC = 0; for (i=n; i > 0; i=i-5) for (j=1; j 0) { if (functionC(n) % 2 == 0) { for (i=m; i > 0; i=i/3) sumE++; } else (10) Asymptotic runtime of functionE { for (i=m; i > 0; i=i-3) sumE--; } n--; } return sumE;arrow_forwardIf we assume that ptr is a reference to an integer, and we add 4 to it, what will happen?arrow_forwardLet A = {a, b, c}, B = {x, y}, and C = {0, 1}.arrow_forward
- c++ computer language randomly generates integers in the interval [1,10] a.1+rand()%11 b.rand()%11 c.rand()%10 d.1+rand()%10arrow_forwardFactorial of a number is defined as: n! = n(n-1)(n-2)(n-3)...(2)(1) For example, 4! = 4*3*2*1 The n! can be written in terms of (n-1)! as: n! = n* (n-1)! (n-1)! = (n-1)*(n-2) ! and so forth. Thus, in order to compute n!, we need (n-1)!, to have (n-1)!, we need (n-2)! and so forth. As you may immediately notice, the base case for factorial is 1 because 1! = 1. Write a program that uses a recursive function called factorial that takes an integer n as its argument and returns n! to the main. C++ PLEASEarrow_forwardFor the given tabulating problem, solve for the needed: Note: This problem was quoted from: An Introduction to Matlab David F. Gri_ths formerly of Department of Mathematics, The University of Dundee, Dundee DD1 4HN Scotland, UK Exercise 14.1 Tabulate the functions y = (x² + 3) sin x² and -2 z=sin? næ/(z~2+3) for x = 0,0.2,..., 10. Hence, tabulate the func- tion (x²+3) sin Tx² sin² Tx (x−²+3) Plot a graph of w over the range 0≤ x ≤ 10. W= - Write a computer algorithm (with python) for tabulating the resulting numbers.arrow_forward
- Show how the letters A, B, and C can be turned into decimal numbers. A.arrow_forwardFind the root of tg(x)=1/2which is between x=0.6 and x=0.7. Use Newton Raphson's method (if it is possible to make a code in matlab)and start calculations with x=0.6.Thanks in advancearrow_forwardWhat is "Approximation Error" in floating-point representation? Why is it happening?arrow_forward
- b) What is the difference between (x++), (x+-), and (--x).arrow_forwardComplete the following sentence. Due to errors during computer calculations, two theoretically equal numbers (e.g. sin(pi) and e) can differ slightly, causing an equality or inequality test to fail.arrow_forwardDo recursive least square in MATLAB with the following data: x = 0:1:9; y = [23.5 24 26 24.5 24.5 27.5 25.5 26 24.5 26.5]; New data that will be added to the datasets are: xnew = [10 11]; ynew = [27.5 23.5];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