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
Cell references in a formula are called _____.<br> a. assumptionsc. numbersb. valuesd. content
Airida [17]
It would bbe d because content is what is in something
7 0
3 years ago
Are storage devices input devices
Nonamiya [84]

Answer:

Exphfbdplanation:

8 0
3 years ago
The homepage is the page your browser displays when you first start the program
soldi70 [24.7K]
Home page usually refers to the page that initially displays if you type in http://www.example.com/  It's usally named index.html, index.shtml or the like.
3 0
3 years ago
Which term refers to a solution to a large problem that is based on the solutions of smaller subproblems. A. procedural abstract
valentina_108 [34]

Answer:

procedural abstraction

Explanation:

5 0
2 years ago
Becky is preparing a document for her environmental studies project. She wants to check her document for spelling and grammar er
Sunny_sXe [5.5K]
If it's MS Word (it probably is), then it's Alt + F7
7 0
2 years ago
Read 2 more answers
Other questions:
  • Lucy has to move data from column A to column N in a worksheet. Which keys should she select to move data in the same worksheet?
    7·2 answers
  • What important information is added to the TCP/IP transport layer header to ensure communication and connectivity with a remote
    13·1 answer
  • This information is generally included on a fax cover sheet.
    15·1 answer
  • Which of the following terms are aspect ratios for devices? 'select all that apply
    11·1 answer
  • The _______ contains the most commonly used commands.
    6·2 answers
  • During a night flight, you observe a steady red light and a flashing red light ahead and at the same altitude. What is the gener
    11·1 answer
  • You are configuring NIC teaming on a server with two network adapters. You chose Switch Independent Mode. You now must choose be
    15·1 answer
  • 80. A .......... is used to read or write data.<br>A. CD B. VDU C. ROM D. RAM​
    6·1 answer
  • Consider our authentication protocol 4.0, in which Alice authenticates herself to Bob, which we saw works well (i.e., we found n
    15·1 answer
  • What is an advantage of using a dynamic hard drive in a vm?
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!