Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

10. (10 points) Write a condition (boolean expression) that evaluates to true if the absolute value of the difference between two double precision floating point

image text in transcribed
10. (10 points) Write a condition (boolean expression) that evaluates to true if the absolute value of the difference between two double precision floating point values, stored in variables d1 and d2, is less than 0.01 (and evaluates to faise otherwise), assuming the following was already declared: final double TOLERANCE 0.01 abs is a static method predefined in the Math class; its header and description in the Java standard lbrary is: static double abs(double a) Returns the absolute value of a double value. 11. a. (5 points) Given a String variable s (already deciared and assigned a value), write code that declares a variable c and assigns to it the last character of s. For example, if s is "top then c should be assigned 'p. This is just an example; your code should work for any String. You will need to invoke some (not all) of the String methods below. b. (10 points) Write a method that receives a String as a parameter, creates a new String that contains the same characters in the specified String but in reverse order, and returns that String. For example, if the String received as a parameter is "top", the method should return "pot", Your method should work for any String You will need to appropriately invoke some (not all) of the methods of the String class. Descriptions of relevant String methods in the Java standard ibrary are: (int index) Returns the char value at the apecified index. Coscatenates the apecified string to the end of this string Returne the length ot thia string Returna a new string that is aaubatring of this atring. The string soocat (String str) int length string substring (int beginTndex) string substring(iat begintadex, int endIndex) substring begins with the character at the specified index and extends to the end of this string Returns a Bev atring that .ubatring of this string. The substring begins al the specified beginIndex and exlends to the charncter at indes end Indexs 1

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

The Database Management Systems

Authors: Patricia Ward, George A Dafoulas

1st Edition

1844804526, 978-1844804528

More Books

Students also viewed these Databases questions

Question

Have you laid out the information as clearly as possible?

Answered: 1 week ago