Question: Java Answer these questions by looking things up in the Java API. Use the following format when making work: copy the task and write a
Java
Answer these questions by looking things up in the Java API.
Use the following format when making work: copy the task and write a code just in the next line.
I. Using the String class
Given the declarationString s = "letterhead";
- Write the expression to find index of the character 'h'.
- Write the expression to retrieve the character 'r'from the String.
- Write the expression to get the substring "ette".
- Write the expression to find the index location of the last 'e'.
II. Using the Math class
- Write the expression to calculate e1.7
- Write the expression to find the larger of two valuesxandy
- Write the expression to generate a random number in the range [0.0, 1.0)
- Write the expression to generate a random number in the range [0.0, 20.0)(hint: this won't be a new method, but will require some math after you make the call).
- Write the expression to generate a random number in the range [5.0, 6.0)(same hint as before).
- Write the expression to generate a random number in the range [10.0, 15.0)(think about combining the 2 steps from 4 and 5).
- Write the expression to generate a random integer in the range [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
III More searching through the API
- Create a statement to instantiate a Point object with coordinates (3, 4) and binding it to an appropriate reference variable.
- What package do you need to import to use a Point object?
- What are the coordinates of a Point object if you don't specify any? (0,0)
- Repeat exercises 3-6 from the Part2 using the Random class.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
