Cruz Space Quantum Vehicles Co. (CSQV Co.) has been very successful. Due to an increase in demand for its CSQVs, the company had to hire thousands of scientists, engineers, and staff from all over the world. As we all know, not all countries use the same system of measurements. The U.S., Liberia and Burma use the English system, while the rest of the world uses the metric system. In addition, scientists use specific scales for some of their applications. To avoid confusion among team members from different countries, the company has commissioned the development and deployment of conversion applications. Your job is to write a program that interchangeably converts between different temperature scales (Celsius, Fahrenheit and Kelvin).
Your job depends on the success of this application. Therefore, make sure you write clean code and test it thoroughly.
1. Display the menu below and get user input. Re-display the menu until the user enters 4.
1- Convert from Celsius
2- Convert from Fahrenheit
3- Convert from Kelvin
4- Quit Program
2. If the user enters 1, prompt the user to enter 3 numbers that represent temperatures expressed in degree Celsius. The program must then convert the temperatures to degree Fahrenheit and Kelvin and output them in a table as follows:
Celsius | Fahrenheit | Kelvin |
-10.00 | 14.00 | 263.15 |
0.00 | 32.00 | 273.15 |
100.00 | 212.00 | 373.15 |
3. If the user enters 2, prompt the user to enter 3 numbers that represent temperatures expressed in degree Fahrenheit. The program should then convert the temperatures to degree Celsius and Kelvin and output them in a table as follows:
Fahrenheit | Celsius | Kelvin |
-10.00 | -23.33 | 249.82 |
0.00 | -17.78 | 255.37 |
100.00 | 37.78 | 310.93 |
4. If the user enters 3, prompt the user to enter 3 numbers that represent temperatures expressed in degree Kelvin. The program should then convert the temperatures to degree Fahrenheit and Celsius and output them in a table as follows:
Kelvin | Fahrenheit | Celsius |
0.00 | -459.67 | -273.15 |
100.00 | -279.67 | -173.15 |
1000.00 | 1340.33 | 726.85 |
5. If the user enters 4, quit the program.
6. Validate input to not accept Kelvin temperatures < 0, Fahrenheit temperature < -459.67 or Celsius temperatures < -273.15.
Needed conversion formulas:
From | To | Formula |
Celsius | Fahrenheit | F = C * (9.0/5.0) + 32 |
Celsius | Kelvin | K = C + 273.15 |
Fahrenheit | Celsius | C = (F - 32) * (5.0/9.0) |
Fahrenheit | Kelvin | K = (F + 459.67) * (5.0/9.0) |
Kelvin | Fahrenheit | F = K * (9.0/5.0) - 459.67 |
Kelvin | Celsius | C = K - 273.15 |
Your program must comply with the following constraints:
1. Must declare at least the following 4 functions:
getMenuSelection() #Displays menu and gets user selection
convertFromCelsius() #From Celsius to the other scales
convertFromFahrenheit() #From Fahrenheit to the other scales
convertFromKelvin() #From Kelvin to the other scales
2. The main function must look exactly as shown below:
def main():
menuSelection = 0
while True:
menuSelection = getMenuSelection()
if menuSelection == 1:
convertFromCelsius()
elif menuSelection == 2:
convertFromFahrenheit()
elif menuSelection == 3:
convertFromKelvin()
elif menuSelection == 4:
break #Exit Condition
else:
print("Please enter a number between 1 and 4")