Question

In c++ format please Most people know that the average human body temperature is 98.6 Fahrenheit...

In c++ format please

Most people know that the average human body temperature is 98.6 Fahrenheit (F). However, body temperatures can reach extreme levels, at which point the person will likely become unconscious (or worse). Those extremes are below 86 F and above 106 F.

Write a program that asks the user for a body temperature in Fahrenheit (decimals are ok). Check if that temperature is in the danger zone (for unconsciousness) or not and produce the relevant output shown below. Also check if the user entered a number greater than zero. If they didn't, display an error message and don't process the rest of this program.

If the entry was valid, convert the temperature from Fahrenheit to Celsius. and output it to the user.

F to C formula: (temp - 32) * 5 / 9

Prompts:

Enter a body temperature in Fahrenheit:

Possible Outputs:

This person is likely unconscious and in danger

Temperature in Celsius is: 41.6667

This person is likely conscious

Temperature in Celsius is: 37

Invalid entry

Notes and Hints:

1) This exercise is testing your knowledge of Flags and Logical Operators. Use both!

2) Do not use constants for the numbers in the F to C formula. Write it as-is.

3) Hint: The order in which you do your decision/conditional statements makes all the difference

4) Remember: Do not let this program do any math if the user's entry is invalid!

Homework Answers

Answer #1


#include <iostream>
using namespace std;
int main() {
double f;
double c=0;
int flag=0;
cout<<"Enter temperature in fahreinheit:";
cin>>f;//read temperature from user
if(f>0){
if(f<86 or f>106){
cout<<"This person is likely unconscious and in danger"<<endl;//check if temperature is extreme
flag=1;
}
else{
cout<<"This person is likely conscious"<<endl;
flag=1;
}
}
else{
cout<<"Invalid entry"<<endl;
}
if(flag==1){
c=(f - 32) * 5 / 9;//convert to celcius and print it
cout<<"Temperature in Celsius is: "<<c<<endl;
}
return 0;
}

Screenshots:

The screenshots are attached below for reference.

Please follow them for output.

Please upvote my answer. Thank you.

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
Please use C++ programming language write a program to convert temperature in Fahrenheit to temperature in...
Please use C++ programming language write a program to convert temperature in Fahrenheit to temperature in celcius.( no comments necessary). get the temperature in Fahrenheit. calculate the temperature in Celsius. and write  the output to screen. Celsius = (5/9) * (F-160)
C++ Fahrenheit to Celsius Tables Write a program that first asks the user which Temperature scale...
C++ Fahrenheit to Celsius Tables Write a program that first asks the user which Temperature scale conversion he/she would like to perform: 1. Convert F to C 2. Convert C to F 3. Quit What is your choice? Then it asks the user for input for three real number variables: start_temp, end_temp, temp_incr. It will then produce a two column Fahrenheit to Celsius table or a two column Celsius to Fahrenheit table, depending on the choice. For choice 1, the...
Selection control structure The if statement The switch statement (optional) Relational operators and logical operators Use...
Selection control structure The if statement The switch statement (optional) Relational operators and logical operators Use of relational and logical operators to check numeric ranges User friendly Use of user friendly user prompt and simple input validation Use of meaningful output labels and format Use of output manipulators Working with string type Use of getline() Project Description There are two main systems for measuring distance, weight and temperature, the Imperial System of Measurement and the Metric System of Measurement. Most...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT