Question

In: Computer Science

Question 4 - Methods (Unit Conversion) Unit conversion is one of those perennial problems that has...

Question 4 - Methods (Unit Conversion)

Unit conversion is one of those perennial problems that has haunted humanity since prehistory. It's notable in that a solution has been widely proposed, studied, and adopted (standardization!) and yet our civilization STILL… well, there's no gentle way to describe our dysfunction here.

Let's take a moment to consider the implications of having (for instance) five different units of temperature: Degrees Kelvin, Degrees Celsius, Degrees Fahrenheit, Rankines, and Cones. In order to perform a direct conversion from, say, Kelvin to all other temperature units, we must determine, maintain, and implement four conversions. The same goes for each of the other units. If we chart these relationships, we might end up with the following representation, which is also called a complete graph.

The driver and function prototype are as follows:

public class Main {

  public static void main( String[] args ) {

    double thermometerTemp = 101.3;

    // The function call occurs here

    double degKelvin = degF_to_degK( thermometerTemp );

    System.out.println( "My temp of (" + thermometerTemp + ") DegF" );

    System.out.println( "Equals a temp of (" + degKelvin + ") DegK" );

  }

  public static <TODO> degF_to_degK( <TODO> temp ) {

    double kelvinResult = <TODO>;

    return kelvinResult;

  }

}

We won't take the time to write other conversions, but you can hopefully see how one could move any arbitrary number of units both to Kelvin by making a set of '_to_degK' functions, then back out using a set of complementary 'degK_to_' functions.

Provide a screenshot demonstrating the Fahrenheit equivalent of:

0 degrees Kelvin // -459.67

273.15 degrees Kelvin // 32

373.2 degrees Kelvin // 212.09

This warm up brings us to the next exercise.

Solutions

Expert Solution

Please look at my code and in case of indentation issues check the screenshots.

-----------------Main.java----------------

import java.util.*;

public class Main
{
   public static void main(String[] args)
   {
       Scanner sc = new Scanner(System.in);
       System.out.print("Enter temperature in degree Kelvin: ");
       double thermometerTemp = sc.nextDouble();                   //read temp in Kelvin from user

       // The function call occurs here
       double degFahrenheit = degK_to_degF(thermometerTemp);       //convert the kelvin temperature to Fahrenheit
       System.out.println("My temp of (" + thermometerTemp + ") DegK");  
       System.out.printf("Equals a temp of (%.2f) DegF\n", degFahrenheit);   //print the result, rounded to 2 decimal places
   }

   public static double degK_to_degF(double kelvinTemp)
   {
       double fahrenheitResult = (9.0 / 5) * (kelvinTemp - 273.15) + 32; //converts kelvinTemp to fahrenheit temperature
        return fahrenheitResult;
   }
}

--------------Screenshots-------------------

------------------Output-----------------

----------------------------------------------------------------------------------------
Please give a thumbs up if you find this answer helpful.
If it doesn't help, please comment before giving a thumbs down.
Please Do comment if you need any clarification.
I will surely help you.

Thankyou


Related Solutions

For the Assembly Department, unit materials cost is $4 and unit conversion cost is $8. All...
For the Assembly Department, unit materials cost is $4 and unit conversion cost is $8. All material costs are added at the beginning of the process and conversion costs are applied uniformly throughout the process. If there are 9900 units in ending work in process 65% complete as to conversion costs, the costs to be assigned to the ending inventory are A.$77220. B.$118800. C.$91080. D. $104940.
Question A: The costs per equivalent unit of direct materials and conversion in the Bottling Department...
Question A: The costs per equivalent unit of direct materials and conversion in the Bottling Department of Rocky Springs Beverage Company are $1.25 and $0.65, respectively. The equivalent units to be assigned costs are as follows: Equivalent Units Direct Materials Conversion Inventory in process, beginning of period 0 2,500 Started and completed during the period 50,000 50,000 Transferred out of Bottling (completed) 50,000 52,500 Inventory in process, end of period 5,000 2,500 Total units to be assigned costs 55,000 55,000...
Create java Class with name Conversion. Instructions for Conversion class: The Conversion class will contain methods...
Create java Class with name Conversion. Instructions for Conversion class: The Conversion class will contain methods designed to perform simple conversions. Specifically, you will be writing methods to convert temperature between Fahrenheit and Celsius and length between meters and inches and practicing overloading methods. See the API document for the Conversion class for a list of the methods you will write. Also, because all of the methods of the Conversion class will be static, you should ensure that it is...
Please answer the question below and clearly explain..........There are four methods of system conversion: parallel, direct...
Please answer the question below and clearly explain..........There are four methods of system conversion: parallel, direct cutover, pilot, and phase‐in. Describe these four methods and how they differ.
Gas Laws Units in Gas Law Problems One problem associated with gas law problems is unit...
Gas Laws Units in Gas Law Problems One problem associated with gas law problems is unit agreement. It is important that pressure, volume and temperature units match or agree within a problem. Solve 1-4 using the factor-label method. Problems 5 and 6 are done without factor-label. 1. Convert 1.52 atm to kPa 2. Convert 85 kPa to mmHg 3. Convert 156.3 mmHg to atm 4. Convert 950 torr to kPa 5. Convert -250.0 °C to K 6. Convert 253 K...
Name one method to eliminate Image Frequency problems. Direct Conversion Receivers are used to receive FM...
Name one method to eliminate Image Frequency problems. Direct Conversion Receivers are used to receive FM broadcasts. True or False Noise is directly proportional to…and… If your signal is 5 uV and the noise is 0.9 uV, what is the S/N Ratio? What is the open circuit noise voltage across a 100 kΩ resistor over the frequency range of DC to 20 Hz at 250C?
there are two primary methods for analyzing ratios. Those two methods are:
there are two primary methods for analyzing ratios. Those two methods are:
Question 1 In March, Kelly Company had the following unit production costs: materials $12 and conversion...
Question 1 In March, Kelly Company had the following unit production costs: materials $12 and conversion costs $7. On March 1, it had no work in process. During March, Kelly transferred out 26,000 units. As of March 31, 3,000 units that were 41% complete as to conversion costs and 100% complete as to materials were in ending work in process. Compute the total units to be accounted for. Total units = Compute the equivalent units of production. The equivalent units...
What are the various kinds of problems that afflict families, and how extensive are those problems?...
What are the various kinds of problems that afflict families, and how extensive are those problems? Explain how family roles can result in both structural and supportive difficulties in families.
4) Short answer question There are those that argue that the current 'unemployment' and inflation numbers...
4) Short answer question There are those that argue that the current 'unemployment' and inflation numbers are not an accurate depiction of the true numbers. Do some digging and see what’s behind those arguments.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT