39.8k views
4 votes
Write a program that will convert a set of temperatures from Fahrenheit to Celsius and Kelvin. Your program will be reading in three double values. The first values are starting and ending temperatures. The third value is the increment value. There is no prompt for the input. There is an error message that can be displayed.

User Linore
by
4.1k points

1 Answer

2 votes

Answer:

start = float(input())

end = float(input())

increment = float(input())

if start <= end and increment > 0:

print("Fahrenheit \t Kelvin \t Celsius")

for f in range(int(start), int(end), int(increment)):

k = 5.0/9.0 * (f - 32) + 273.15

c = (f - 32) / 1.80

print("%.2f" % f + "\t\t" + "%.2f" % k + "\t\t" + "%.2f" % c)

else:

print("Invalid input!")

Step-by-step explanation:

The code is in Python.

Let the user enter three values, start, end, and increment

Check the values. If start is smaller than or equal to end and increment is greater than zero:

Create a for loop that iterates between start and end with the increment value. Convert each of the value to kelvin and celsius using the formulas. Print the each value.

Otherwise, print invalid input

User Thrax
by
5.2k points