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

Write java program 1. Assume that two classes \'Temperature\' and \'Sensor\' hav

ID: 3741974 • Letter: W

Question

Write java program

1. Assume that two classes 'Temperature' and 'Sensor' have been defined. 'Temperature' has a constructor that accepts a double parameter. 'Sensor' has a methodnamed 'getReading' which returns the sensor's current reading (a double). Write a static method 'create' (that could be added to the 'Temperature' class) that accepts a 'Sensor' object. 'create' gets the value of the current reading of the 'Sensor' object, and returns a new 'Temperature' object that is based on this reading.

2.Write the code for invoking a static method named sendTwo, provided by the DataTransmitter class. There are two arguments for this method: a double and an int. Invoke the method with the double value of 15.955 and the int value of 133.

3.Assume the availability of class named Logger that provides a static method, printErrorDescription, that accepts one int argument and returns no value.

Write a statement that invokes the method printErrorDescription, passing it the value 14.

Explanation / Answer

Please find the cod below.

CODE

=================

class Sensor {

   private double reading;

   public double getReading() {

       return reading;

   }

}

class Temperature {

   public Temperature(double val) {

      

   }

  

   public static Temperature create(Sensor sensor) {

       return new Temperature(sensor.getReading());

   }

}

class DataTransmitter {

   public static void sendSignal () {

   }

  

   public static void sendNumber (int num) {

   }

  

   public static void sendDouble (double num) {

   }

  

   public static void sendTwo(double a, int b) {

   }

}

public class Main

{

   public static void main(String[] args)

   {  

       DataTransmitter.sendTwo(15.955, 133);  

       Logger.printErrorDescription(14);

   } // end main()

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote