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
The advantages of the DecimalFormat class compared with the NumberFormat class include Group of answer choices
Anon25 [30]

Answer:5. only A and B(precise control over the number of digits to be displayed and control over the presence of a leading zero)

Explanation: DECIMAL FORMAT CLASS is a subclass of Number format class specifically made to format parsing decimal Numbers. It is capable of formating both ARABIC, WESTERN AND INDIC DIGITS. It has a unique Attribute of control over the number of digits to be displayed and control over the presence of a leading zero.

NUMBER FORMAT CLASS is the class for formatting parsing numbers it helps to format According to Specific locale.

3 0
3 years ago
What is the hexadecimal equivalent for 11000101?
Makovka662 [10]

Answer: C5₁₆ ⇔ 11000101₂ ⇔ 197⏨

Explanation: 11000101 is a binary number

it's equivalent decimal number is

1x2⁷+ 1x2⁶+0x2⁵ + 0x2⁴+0x2³+1x2²+0x2¹+1x2⁰ = 128+64+4+1 = 197

Hexadecimal system has equivalents in decimal system

0 ⇔0

1 ⇔ 1

2 ⇔ 2

3 ⇔ 3

4 ⇔ 4

5 ⇔ 5

6 ⇔ 6

7 ⇔ 7

8 ⇔ 8

9 ⇔ 9

10 ⇔A

11 ⇔B

12 ⇔C

13 ⇔D

14 ⇔E

15 ⇔F

197 ⇔??

To convert this decimal number in a hexadecimal number we have to divide it by 16

197/16

12,...

the quotient without the decimal part is multiplied by 16 and subtracted from the number

12x16 = 192

197-192 = 5

Then this number can be expressed as 12x16¹ + 5x16⁰ = 192 + 5 = 197

But in the hexadecimal system there are not digits > 9 , so 12 ⇔ C

197⏨ = Cx16¹ + 5x16⁰ = C5₁₆

Answer: C5₁₆ ⇔ 11000101₂ ⇔ 197⏨

\textit{\textbf{Spymore}}

8 0
2 years ago
When choosing a communication channel, _____refers to the degree to which communications can be planned and recorded, thus allow
steposvetlana [31]

Answer: Control

Explanation: Communication channel is the medium created for the process of the communication.These channel let the source to destination communication in a cycle so that message can be send and received respectively.

Control in the branch of communication channel is used for the handling of the communication limit of the message that is being sent and received .It puts a limitation to the extent message can be read, recorded ,movement of resource and other facilities.

4 0
3 years ago
Write assignment statements that perform the following operations with the variables a, b, and c. i. Adds 2 to ‘a’ and assigns t
solniwko [45]
<h2>Answer: </h2>

(i) b = a + 2;

(ii) a = b * 4;

(iii) b = a / 3.14;

(iv) a = b - 8;

<h2>Explanation: </h2><h3>Assumptions and comments; </h3>

=> The code has been written in Java.

=> The variable a, b and c have been declared.

=> The variable c has only been declared but not used since it is not part of the assignment procedures.

<h3>Explanation: </h3>

The following is the assignment statement that;

<em>(i) Adds 2 to ‘a’ and assigns the result to ‘b’</em>

To add a number to another number or variable, the arithmetic operator (+) is used using the following syntax;

[number] [+] [other number]

In our case, the number is variable a and the other number is 2. Therefore, to add these numbers together we write;

a + 2;

Also, assignment in programming languages is done using the (=) operator. For example to assign a number k to a variable m, we write;

m = k

In our case, the result (a + 2) from above is assigned to variable b as follows;

=> b = a + 2

<em>(ii) Multiplies ‘b’ times 4 and assigns the result to ‘a’.</em>

To multiply a number by another number or variable, the arithmetic operator (*) is used using the following syntax;

[number] [*] [other number]

In our case, the number is variable b and the other number is 4. Therefore, to multiply these numbers we write;

b * 4;

Also,

In our case, the result (b * 4) from above is assigned to variable a as follows;

=> a = b * 4

<em>(iii) Divides ‘a’ by 3.14 and assigns the result to ‘b’.</em>

To divide a number by another number or variable, the arithmetic operator (/) is used using the following syntax;

[number] [/] [other number]

In our case, the number is variable a and the other number is 3.14. Therefore, to divide these numbers we write;

a / 3.14;

Also,

In our case, the result (a / 3.14) from above is assigned to variable b as follows;

=> b = a / 3.14

<em>(iv) Subtracts 8 from ‘b’ and assigns the result to ‘a’.</em>

To subtract a number from another number or variable, the arithmetic operator (-) is used using the following syntax;

[other number] [-] [number]

In our case, the number is 8 and the other variable is b. Therefore, to subtract these numbers we write;

b - 8;

Also,

In our case, the result (b - 8) from above is assigned to variable a as follows;

=> a = b - 8;

3 0
3 years ago
Create a class RightTriangle which implements the API exactly as described in the following JavadocLinks to an external site..
WARRIOR [948]

Answer:

I don't see anything. Its blank

Explanation:

3 0
2 years ago
Other questions:
  • on average, someone with a bachelor’s degree is estimated to earn _______ times more than someone with a high school diploma
    13·1 answer
  • In which phase of the software development process would probing questions be used to verify the problem definition?
    12·1 answer
  • Two boxes overlap if their interiors have at least one point in common. Give an O(n log n)-time algorithm that decides if there
    8·1 answer
  • The capacity of a communication channel is measured in _______.
    6·2 answers
  • Which of the following sentences is accurate? a. PDF stands for "Proofreading Direct Files." b. PDF files cannot be edited. c. B
    9·1 answer
  • What does cmyk stand for?
    5·2 answers
  • CAN SOMEONE PLEASE DO THESE FOR ME I WILL GIVE BRAINLIESR AND 20 POINTS PLEASE ITS ONLY 5 QUESTIONS PLEASEEEE
    12·1 answer
  • In the welding operations of a bicycle manufacturer, a bike frame has a long flow time. The set up for the bike frame is a 7 hou
    10·1 answer
  • IN PYTHON LANGUAGE
    9·2 answers
  • Northern Trail Outfitters uses a custom object Invoice to collect customer payment information from an external billing system.
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!