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...
Create java class with name MyClass1 Instructions for MyClass1 For this portion of the assignment you...
Create java class with name MyClass1 Instructions for MyClass1 For this portion of the assignment you will need to create a java class of your own to model some objects in the real world or your own imagination. your classes should have at least three instances variables, accessor and mutator methods for each of those instance variables, one constructor method of any type, as well as an overridden toString method that will display every field value as part of a...
java Objective: Create a class. Create objects. Use methods of a class. Create a class BankAccount...
java Objective: Create a class. Create objects. Use methods of a class. Create a class BankAccount to represent a bank account according to the following requirements: A bank account has three attributes: accountnumber, balance and customer name. Add a constructor without parameters. In the initialization of the attributes, set the number and the balance to zero and the customer name to an empty string. Add a constructor with three parameters to initialize all the attributes by specific values. Add a...
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):...
Create a Class with Data Fields and Methods in Java. Provide a Java coding solution for...
Create a Class with Data Fields and Methods in Java. Provide a Java coding solution for the following: 1. Name the class SalonServices 2. Add private data fields: a. salonServiceDescription – This field is a String type b. price - This field is a double type 3. Create two methods that will set the field values. a. The first method setSalonServiceDescription() accepts a String parameter defined as service and assigns it to the salonServiceDescription. The method is not static b....
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...
Create a Java class with the name (identifier) MyProgram and place it in the Questions package....
Create a Java class with the name (identifier) MyProgram and place it in the Questions package. You will need to create a main method for this class and place all of your code inside of that method. Your program should complete the following steps: - Prompt the user to enter a name for a Student. - Use the Scanner class to read in the user input and store the result in a variable. - Use the Random class to generate...
Create in Java Create a stack class to store integers and implement following methods: 1- void...
Create in Java Create a stack class to store integers and implement following methods: 1- void push(int num): This method will push an integer to the top of the stack. 2- int pop(): This method will return the value stored in the top of the stack. If the stack is empty this method will return -1. 3- void display(): This method will display all numbers in the stack from top to bottom (First item displayed will be the top value)....
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.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT