Question: 2 Temperature Conversion In the provided Convert.java file, complete the convert ( String , Char ) method. The method takes a String and a char
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 temperature, char scale
The input String temperature has both a value and scale and will always be in the form xyS
where is a decimal number like or 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 and 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 CF
and C The second input, scale, must be the char or
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 returns
Convert.convertreturns
Convert.convertreturns
Note that you are using floating point numbers in this problem. Because of this, if you expect
your result to be a number like and you actually get something like or
don't worry, that is fine. Remember representational error! However,
if you expect and you get then something went wrong. Our testing will consider two
numbers like and as being the same. In fact, if
two numbers and satisfy 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 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.convertFCreturns
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
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
