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 false 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 library is: static double abs(double a) Returns the absolute value of a double value. 11. a. (5 points) Given a String variable s (already declared 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 library are: char charat (int index) Returns the char value at theecified index. Concatenates the specified atring to the end of this string. Returns the length of this string. Returns a new string that is a subatring of this string. The String concat (String str) int length0 string substring (int beginIndex) string aubstring (int beginIndex, int endIndex) substring begins with the character at the specified index and extends to the end of this string. Returns a new string that is a subatring of this string. The substring begins at the specified beginIndex and extends to the character at index endIndex 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

Database Management Systems Designing And Building Business Applications

Authors: Gerald V. Post

1st Edition

0072898933, 978-0072898934

Students also viewed these Databases questions