
Concept explainers
Write a Python program that prompts the user to enter a numeric temperature value that may be a float. A second prompt should then ask the user to indicate whether the user wants the entered temperature value converted to degrees Celsius or degrees Fahrenheit by entering either an 'F' or a 'C' for a second prompt.
For example, if the user enters 212 at the first prompt and the character C for the second prompt you are to convert 212 degrees F to the Celsius equivalent (which would be 100.0). Converted temperatures should be rounded to 1 decimal place.
If the user enters 26 at the first prompt and the character F at the second one, then your programs should convert 26 degrees C to the Fahrenheit equivalent (which is 78.8 deg F)
Your conversion formulas are:
degF = 1.8 * degC + 32 //convert Celsius to Fahrenheit
degC = (degF - 32) / 1.8 //convert Fahrenheit to Celsius
- Have your converted values be floats rounded to 1 decimal place.
- The F or C entry should be case-insensitive. The user should be able to enter F or f for a Fahrenheit conversion, or a C or c for a Celsius conversion. But if the user doesn't enter an F, f, C or c, then display an error message and exit the program rather than performing the calculation
- Use the decision structure of your choosing to determine whether to convert the input value to degF or degC or to exit.
- Your output should contain both the original temperature entered and the proper output temperature, labeled as to which is which. Something like this: 212 degrees F = 100.0 degrees C
![Your prompt strings might look something like this, although you can choose your own words.
Please enter a temperature value to convert:
Convert to Fahrenheit or Celsius? Enter either F or C:
A possible example program run might look like this, where 50 deg C is converted to 122.0 deg F. Your output should indicated
which number is in which temperature system, like the following.
76 Python Shell
File Edit
Shell Debug Options Windows Help
Python 3.3.0 (v3.3.0:bd8afb90ebf2, Sep 29 2012, 10:55:4
8) [MSC v.1600 32 bit (Intel)] on win32
Type "copyright", "credits" or "license ()" for more inf
ormation.
>>>
RESTART
>>>
Enter a temperature value to convert: 50
Convert to Fahrenheit or Celsius? Enter F or C: f
50.0 deg C = 122.0 degrees F
>>> |
And, what if the user does not enter an F, f, C, or c? Suppose they type in k or simply hit enter without typing any character at
all?. Then your output should look similar to the following. You do not have to account for all possible user input errors, and for
this program you can assume the user will not enter a number that is lower than absolute zero.
76 Python Shell
File Edit Shell Debug Options Windows Help
Python 3.3.0 (v3.3.0:bd8afb90ebf2, Sep 29 2012, 10:55:4
8) [MSC v.1600 32 bit (Intel)] on win32
Type "copyright", "credits" or "license () " for more inf
ormation.
>>>
RESTART
==
>>>
Enter a temperature value to convert: 45.2
Convert to Fahrenheit or Celsius? Enter F or C: m
You did not enter an F or C.
Goodbye
>>> |
If you get good and stuck email me your code and we'Il get it working.](https://content.bartleby.com/qna-images/question/b12e7222-506e-487d-a20e-061b70f8136b/e894b3aa-bc07-46f6-a3c4-d722f3fc4883/whpvxq_thumbnail.png)

Trending nowThis is a popular solution!
Step by stepSolved in 4 steps with 3 images

The code works, execpt:
Have your converted values be floats rounded to 1 decimal place.
How do you make it round to 1 decimal place?
The code works, execpt:
Have your converted values be floats rounded to 1 decimal place.
How do you make it round to 1 decimal place?
- Write a Flowgorithm program that will calculate a mobile phone bill based on the customer plan and the data used. The program should perform the following: Prompt for input of customer name Prompt for input of customer’s mobile plan Prompt for input of number of gigabytes of data used If the plan choice is invalid or gigabytes used is less than zero (0) display a message and terminate program Calculate the monthly bill based on plan & data usage Display customer name, plan and monthly mobile charges Mobile data plans are: Plan A 19.99/month, w/6 gigs of data, additional data $8.50/gig Plan B 29.99/month, w/10 gigs of data, additional data $3.50/gig Plan C 39.99/month, unlimited dataarrow_forwardWrite a program that converts a temperature from Fahrenheit to Celsius. It should do the following: Prompt the user for input Read a double value from the keyboard Calculate the result. Here is the formula: C = (F - 32) * 5 / 9 Format the output to one decimal place. Your prompt to the user to enter the temperature in Celsius must be: Enter the Fahrenheit Temperature as a decimal: Your output must be of the format: fahrenheitTemperature F = celsiusTemperature C A sample run with input 75.2 must look like: Enter the temperature in degrees celsius: 75.2 75.2 F = 24.0 C A sample run with input 7.5 must look like: Enter the temperature in degrees celsius: 7.5 7.5 F = -13.6 C Hint1: Be careful not to use integer division! Here is the formula again: C = (F - 32) * 5 / 9 Hint2: Remember to use printf to format the output. Please make sure to end each line of output with a newline. Please note that your class should be named…arrow_forwardWrite a program that asks the user to enter 2 integers of 4 digits and displays thedifferent digits as X and * if they are the same. If the user enters a number which is notof four digits, then a convenient message is displayed.arrow_forward
- The code must be in Java language The program will find all of the Fibonacci numbers which are also prime numbers in the range from 2 to 500,000. Print each value which meets these criteria on a separate line in your output. Do not print values which do not meet the criteria.arrow_forwardI'm stuck on this problem, and here's what I'm stumped on: Meadowdale Dairy Farm sells organic brown eggs to consumers in the surrounding area. For a dozen eggs, it charges $3.25, and for individual eggs that are not part of a dozen, it charges 45 cents each egg. Using the following phrasing, write a program that prompts a user to enter the number of eggs in the order and then displays the amount owed along with a detailed explanation of why the amount is due: You placed an order for 27 eggs. There are 2 dozen eggs at $3.25 per dozen and 3 loose eggs at 45 cents each, which adds up to a total of $7.85.arrow_forwardWrite a program that prompts the user to enter a decimal integer and displays its corresponding hexadecimal value.arrow_forward
- please use pythonarrow_forwardGiven a positive integer n, the following rules will always create a sequence that ends with 1, called the hailstone sequence: If n is even, divide it by 2 If n is odd, multiply it by 3 and add 1 (i.e. 3n +1) Continue until n is 1 Write a program that reads an integer as input and prints the hailstone sequence starting with the integer entered. Format the output so that ten integers, each separated by a tab character (\t), are printed per line. The output format can be achieved as follows:System.out.print(n + "\t"); Ex: If the input is: 25 the output is: 25 76 38 19 58 29 88 44 22 11 34 17 52 26 13 40 20 10 5 16 8 4 2 1 (NEED HELP IN JAVA PLEASE)arrow_forwardPhyton Develop a program that reads a four-digit integer from the user and displays the sum of its digits. For example, if the user enters 3141 then your program should display 3+1+4+1=9.arrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education





