Question: 2 Temperature Conversion In the provided Convert.java file, complete the convert ( String , Char ) method. The method takes a String and a char

2 Temperature Conversion
In the provided Convert.java file, complete the convert (String, Char) method. The method
takes a String and a char as input and outputs (returns) a double.
public static double convert(String temperature, char scale){dots}
The input String temperature has both a value and scale and will always be in the form "x.yS",
where x.y is a decimal number like 10.1,0.0, or -15.3. It always has a number before the decimal
point (it might be negative), the decimal point itself and at least one digit to the right of the
decimal point. So,10 and .3 are not valid. The last character in this String will cither be C (for
Celsius) or F (for Fahrenheit). Examples of valid input for temperature are "10.0C","-12.29F",
and "1010.7C". The second input, scale, must be the char 'C','c','F', or 'f'.
The method will take the input temperature and convert it to the specified scale, outputting
(returning) the resulting temperature value. Here are some examples.
Convert.convert(10.0C'''F')rarr returns 50.0
Convert.convert(10.2C',?'C')returns10.2
Convert.convert(40.0C,'F')returns-40.0
Note that you are using floating point numbers in this problem. Because of this, if you expect
your result to be a number like 50.0 and you actually get something like 50.00000000000000020 or
49.99999999999999999787, don't worry, that is fine. Remember representational error! However,
if you expect 1.0 and you get 1.01 then something went wrong. Our testing will consider two
numbers like 1.00000000000000020 and 0.99999999999999999787 as being the same. In fact, if
two numbers x and y satisfy |x-y|lon for some small , for example) then we consider
the two numbers to be the same.
If your method is called and the output is less than absolute zer ?2?2 then instead of returning the
number you computed, you will instead return the appropriate value of absolute zero (in the scale
specified by scale). An example, of this special case, would be
Convert.convert("-875.0F",'C')returns-273.15
There is a main() method that can be used as a basic tester for your code. Note that you
should add more test cases than the ones provided to ensure your methods are correct. When you
submit, we will not be running this file as a program. Instead, we will use another program to call
your function. But, your Convert.java file must compile without error to receive marks.
Submit your Convert. java file to Gradescope (along with your other java files).
2 Temperature Conversion In the provided

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!