1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Annette [7]
3 years ago
5

Write a Temperature class that will hold a temperature in Fahrenheit, and will provide methods to get and display the temperatur

e in Fahrenheit, Celsius, and Kelvin. The Temperature class should have the following instance variable: ftemp – A double that holds a Fahrenheit temperature. The Temperature class should have the following methods: ReadInput – Uses a Scanner method to populate ftemp with double value. getFahrenheit – Returns the value of the ftemp field, as a Fahrenheit temperature. getCelsius – Returns the value of the ftemp field converted to Celsius. getKelvin – Returns the value of the ftemp field converted to Kelvin. DisplayOutput – The Fahrenheit temperature and the equivalent values in Celsius and Kelvin are gotten and displayed, one per line, and each along with an appropriate message.
Computers and Technology
1 answer:
natita [175]3 years ago
8 0

Answer:

See explaination

Explanation:

import java.util.Scanner;

public class TemperatureTest {

public static void main(String[] args) {

Scanner sc = new Scanner(System.in);

System.out.print("Enter Fahrenheit temperature: ");

double ftemp = sc.nextDouble();

Temperature temp = new Temperature(ftemp);

System.out.println("The temperature in Fahrenheit is " + temp.getFahrenheit());

System.out.println("The temperature in Celsius is " + temp.getCelsius());

System.out.println("The temperature in Kelvin is " + temp.getKelvin());

}

}

class Temperature {

double ftemp;

Temperature(double ftemp) {

this.ftemp = ftemp;

}

double getFahrenheit(){

return ftemp;

}

double getCelsius(){

return ((double)5/9*(ftemp-32));

}

double getKelvin(){

return (((double)5/9*(ftemp-32))+273);

}

}

Output:

$ java TemperatureTest

Enter Fahrenheit temperature: -40

The temperature in Fahrenheit is -40.0

The temperature in Celsius is -40.0

The temperature in Kelvin is 233.0

You might be interested in
Which structures protect the cell? Select two options.
Rzqust [24]

Answer:

cell wall

cell membrane

3 0
2 years ago
What is Dailymotion Cloud on the Dailymotion site?
lana [24]
C, a video solution that is adaptable to the users storage space
4 0
3 years ago
Read 2 more answers
Many professional photographers take pictures of people. What skills would someone have to have to be successful in these types
Galina-37 [17]
Wedding photographer
you are taking pictures of large groups of all kinds of people from 2 different sides of a family 

could you add me as best answer if this is correct?

7 0
3 years ago
Technician A says that there are two types of battery cells, primary (non-rechargable) and secondary. Technician B says there ar
Scrat [10]

Technician A is correct.

Electrochemical batteries can be classified into two main categories; Primary Cells and Secondary Cells.

A primary battery or cell cannot easily be recharged after use and is usually recommended to be discarded following discharge. Most primary cells are termed dry due to their capability of utilizing electrolytes contained within absorbent material.

A secondary cell, on the other hand, can be recharged electrically to their original pre-discharge condition.

4 0
3 years ago
Read 2 more answers
What does the following code alert?
goldenfox [79]

It is just a declaration of an object variable, <em>person</em>, in JavaScript. Within a <em>person</em> object, there are key:value pairs. The code that you  shared has the following keys: name, age, and favouriteFood, whereas the values of those keys are: Mike, 25, and pizza.


There is <em>no</em> alert statement in this code snippet; therefore, it <em>will not alert </em>anything. This code contains only a variable called <em>person, </em>and that's it!

5 0
3 years ago
Read 2 more answers
Other questions:
  • Technician A says that the push rod connects to a pivoting component mounted at the top of the cylinder head called the camshaft
    14·2 answers
  • Fill the validateForm function to check that the phone number contains a number (use the isNaN function) and that the user name
    8·1 answer
  • You are the CISO of a company and you need to create logging policies. Please review NIST SP800-92, specifically sections 4–3 th
    12·1 answer
  • Which of the following are not parts of a message? Select all that apply.
    12·1 answer
  • To implement a small database, a database designer must know the "1" and the "M" sides of each relationship and whether the rela
    13·1 answer
  • Providing incentives for customers to learn more about your service is known as?
    7·1 answer
  • Which type of film would typically require the least amount of input from a screenwriter?
    10·1 answer
  • What is polymerization1​
    11·1 answer
  • I dont uderstand dis my teacher no helping pls help me i need to understand TEch
    10·1 answer
  • Which technology will a business use to identify unauthorized access to intranet sites or files by its employees?
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!