Question

In: Computer Science

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 not possible to create any instances of the class. You can do this by declaring a default constructor method using the private access modifier.

API Document

Methods:

Identifier:

celsiusToFahrenheit(int temp)

Parameters:

temp – An int type specifying the temperature in degrees Celsius

Return Value:

int – The value of the parameter converted to Fahrenheit.

Other:

This method should be static

Identifier:

fahrenheitToCelsius(int temp)

Parameters:

temp – An int type specifying the temperature in degrees Fahrenheit.

Return Value:

int – The value of the parameter converted to Celsius.

Other:

This method should be static

Identifier:

metersToInches(int meters)

Parameters:

meters – An int type specifying the number of meters.

Return Value:

int – the number of inches in the parameter.

Other:

This method should be static

Identifier:

inchesToMeters(int inches)

Parameters:

inches – An int type specifying the number of inches.

Return Value:

int – the number of meters in the parameter.

Other:

This method should be static

Identifier:

celsiusToFahrenheit(double temp)

Parameters:

temp – A double type specifying the temperature in degrees Celsius

Return Value:

double – The value of the parameter converted to Fahrenheit.

Other:

This method should be static

Identifier:

fahrenheitToCelsius(double temp)

Parameters:

temp – A double type specifying the temperature in degrees Fahrenheit.

Return Value:

double – The value of the parameter converted to Celsius.

Other:

This method should be static

Identifier:

metersToInches(double meters)

Parameters:

meters – A double type specifying the number of meters.

Return Value:

double – the number of inches in the parameter.

Other:

This method should be static

Identifier:

inchesToMeters(double inches)

Parameters:

inches – A double  specifying the number of inches.

Return Value:

double – the number of meters in the parameter.

Other:

This method should be static

Solutions

Expert Solution

public class Conversion {

   private Conversion(){
      
   }
   public static int celsiusToFahrenheit(int temp){
       return 9*temp/5 + 32;
   }
   public static int fahrenheitToCelsius(int temp){
       return ((temp - 32)*5)/9;
   }
   public static int metersToInches(int meters){
       return (int) (meters*39.3701);
   }
   public static int inchesToMeters(int inches){
       return (int) (inches * 0.0254);
   }
   public static double celsiusToFahrenheit(double temp){
       return 9*temp/5 + 32;
   }
   public static double fahrenheitToCelsius(double temp){
       return ((temp - 32)*5)/9;
   }
   public static double metersToInches(double meters){
       return meters*39.3701;
   }
   public static double inchesToMeters(double inches){
       return inches * 0.0254;
   }
}


Related Solutions

Create a java class with name Cat. Instructions for Cat class: This class is modeled after...
Create a java class with name Cat. Instructions for Cat class: This class is modeled after a Cat. You should have instance variables as follows: The Cat’s name The number of mice caught by the Cat. Whether or not the Cat is secretly plotting to kill you Note that you will need to choose both good types and meaningful identifiers for each of these instance variables. You may also assume that the Cat is not automatically always secretly plotting to...
Create java class with name BaseballPlayer Instructions for BaseballPlayer class: The BaseballPlayer class is modeled after...
Create java class with name BaseballPlayer Instructions for BaseballPlayer class: The BaseballPlayer class is modeled after a BaseballPlayer and will contain methods to calculate various statistics based on the stats of a player. For this class, you will want to use a static variable for storing a DecimalFormat object. See the API document for the BaseballPlayer class for a list of methods you will write. API Document Constructors: Identifier: BaseballPlayer(String name, int number, int singles, int doubles, int triples, int...
Code in Java 1. Create a class Flower with data: Name, Price, Color and properly methods....
Code in Java 1. Create a class Flower with data: Name, Price, Color and properly methods. 2. Create another class named ListFlower. This class manages a collection of Flower (may be LinkedList) named a. Implementing some methods for ListFlower: Add: add new item of Flower to a Display: display all items of a sort(): sort as descending by Price and display all items of a search(Flower f): check and return whether f is exists in a or not. delete(int pos):...
THIS IS JAVA PROGRAMMING 1. Create a class named Name that contains the following: • A...
THIS IS JAVA PROGRAMMING 1. Create a class named Name that contains the following: • A private String to represent the first name. • A private String to represent the last name. • A public constructor that accepts two values and assigns them to the above properties. • Public methods named getProperty (e.g. getFirstName) to return the value of the property. • Public methods named setProperty ( e.g. setFirstName)to assign values to each property by using a single argument passed...
java code Add the following methods to the LinkedQueue class, and create a test driver for...
java code Add the following methods to the LinkedQueue class, and create a test driver for each to show that they work correctly. In order to practice your linked list cod- ing skills, code each of these methods by accessing the internal variables of the LinkedQueue, not by calling the previously de?ined public methods of the class. String toString() creates and returns a string that correctly represents the current queue. Such a method could prove useful for testing and debugging...
Program in Java Create a class and name it MyArray and implement following method. * NOTE:...
Program in Java Create a class and name it MyArray and implement following method. * NOTE: if you need more methods, including insert(), display(), etc. you can also implement those. Method name: getKthMin(int k) This method receives an integer k and returns k-th minimum value stored in the array. * NOTE: Items in the array are not sorted. If you need to sort them, you can implement any desired sorting algorithm (Do not use Java's default sorting methods). Example: Items...
Java: Create a class and name it MyArray and implement following method. * NOTE: if you...
Java: Create a class and name it MyArray and implement following method. * NOTE: if you need more methods, including insert(), display(), etc. you can also implement those Method name: getKthMin(int k) This method receives an integer k and returns k-th minimum value stored in the array. * NOTE: Items in the array are not sorted. If you need to sort them, you can implement any desired sorting algorithm (Do not use Java's default sorting methods). Example: Items in the...
Program in Java Create a class and name it MyArray and implement following method. * NOTE:...
Program in Java Create a class and name it MyArray and implement following method. * NOTE: if you need more methods, including insert(), display(), etc. you can also implement those. Method name: getKthMin(int k) This method receives an integer k and returns k-th minimum value stored in the array. * NOTE: Items in the array are not sorted. If you need to sort them, you can implement any desired sorting algorithm (Do not use Java's default sorting methods). Example: Items...
1. Please create a New Class with the Class Name: Class17Ex Please add the ten methods:...
1. Please create a New Class with the Class Name: Class17Ex Please add the ten methods: 1. numberOfStudents 2. getName 3. getStudentID 4. getCredits 5. getLoginName 6. getTime 7. getValue 8. getDisplayValue 9. sum 10. max Show Class17Ex.java file with full working please. Let me know if you have any questions.
Create a Class to contain a customer order Create attributes of that class to store Company...
Create a Class to contain a customer order Create attributes of that class to store Company Name, Address and Sales Tax. Create a public property for each of these attributes. Create a class constructor without parameters that initializes the attributes to default values. Create a class constructor with parameters that initializes the attributes to the passed in parameter values. Create a behavior of that class to generate a welcome message that includes the company name. Create a Class to contain...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT