Question
Design and implement an application to convert temperatures from Fahrenheit to Celsius or Celsius to Fahrenheit. Create a menu based application with 3 options, Convert
Design and implement an application to convert temperatures from Fahrenheit to Celsius or Celsius to Fahrenheit. Create a menu based application with 3 options, Convert Fahrenheit to Celsius, Convert Celsius to Fahrenheit, and Exit. You'll need a conditional loop and a sentinel value, (For Example: X to Exit). Look for opportunities in the design to implement one or more GLOBAL CONSTANTs.
Having trouble using a sentinel value in a while loop. 3 would be the value....but not sure how to go about it.
print( '1. Convert Fahranheit to Celcius')
print('2. Convert Celcius to Fahrenheit')
print('3. Exit')
while True:
task=input('Enter the number to perform the corresponding task:')
if task == '1': fahrenheit=float(input('Enter the temperature in fahrenheit:')) celsius = (fahrenheit-32)*5/9
print'%.2f Fahrenheit is: %0.2f Celsius' %(fahrenheit, celsius))
if task == '2': celsius = float(input("Enter temperature in celsius: ")) fahrenheit = (celsius * 9/5) + 32
print('%.2f Celsius is: %0.2f Fahrenhei' %(celsius, fahrenheit))
Step by Step Solution
There are 3 Steps involved in it
Step: 1
import javautilScanner Main class public class Temperatures Global constants public static int F...Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started