Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Create a Java program that performs the following tasks: 1. Generate three (3) r

ID: 3662070 • Letter: C

Question

Create a Java program that performs the following tasks:

1. Generate three (3) random numbers (input)

Note: A constant seed value will ensure the same three values are generated with each program run.

A. Temperature in Fahrenheit between 0 and 212

B. Distance in Feet between 0 and 100

C. Weight in Pounds between 0 and 100

2. Convert the three input values using the p rovided equations (output )

A. Temperature

1. Celsius = ( Fahrenheit – 32) * 5 / 9

2. Kelvin = ( Fahrenheit + 459.67) * 5 / 9

B. Distance

1. Meters = Feet * 0.3048

2. Inches = Feet * 12

C. Weight

1. Kilograms = Pounds * 0.4536

2. Stones = Pounds * 0.0714285714

3. Display the input and output values (see Example Output section)

Notes: Display homework number and programmer’s identifier at top of program output. Use a Driver class with an execute method that controls the execution of the program Ensure source code comments conform to class commenting standards. Ensure program development conforms to class programming standards. Submit the project source code as a single *.java file

Example Output Homework 1 Ima Java Programmer Original Value Converted To Value Converted To Value Fahrenheit Feet Pounds 212 100 100 Celsius MeterS Kilograms 100.000 30.480 45.360 Kelvin Inches Stones 373.150 1200.000 7.143

Explanation / Answer

Conversion.java
import java.util.Random;

public class Conversion{
  
   public static void main(String args[])
   {
       double tempCelsius=0,tempKelvin=0,distMeters=0,distInches=0,weightKg=0,weightStones=0;
      
       Random rand=new Random();
       rand.setSeed(42);
      
       //Generating 3 random numbers as input
       int temp=rand.nextInt(213);
       int distance=rand.nextInt(101);
       int weight=rand.nextInt(101);
      
       //Converting temperature in Fahrenheit to Celcius and Kelvin
       tempCelsius=(temp-32)*5/9;
       tempKelvin=(temp+459.67)*5/9;
       //Converting distance in Feet to Meters and Inches
       distMeters=distance*0.3048;
       distInches=distance*12;
       //Converting weight in Pounds to Kilograms and Stones
       weightKg=weight*0.4536;
       weightStones=weight*0.0714285714;
      
       System.out.format("%15s%8s%15s%10s%16s%10s",
           "Original", "Value", "Converted To", "Value", "Converted To","Value");
       System.out.println();
       System.out.format("%15s%8d%15s%11f%15s%14f", "Fahrenheit", temp,
               "Celsius", tempCelsius, "Kelvin", tempKelvin);
       System.out.println();
       System.out.format("%15s%8d%15s%11f%15s%14f", "Feet", distance,
               "Meters", distMeters, "Inches", distInches);
       System.out.println();
       System.out.format("%15s%8d%15s%11f%15s%14f", "Pounds", weight,
               "Kilograms", weightKg, "Stones", weightStones);
      
   }
}