Question

In: Computer Science

– 28 – It is freezing out, wear a winter coat 29 – 49 – It...

– 28 – It is freezing out, wear a winter coat
29 – 49 – It is fairly cold, wear a jacket
50 – 78 – Weather is nice out, wear whatever
79 – 100 – It’s piping hot out, keep it light


Write a code snippet that asks the user to enter in the temperature in Fahrenheit, and outputs the matching message that tells the state of weather and what to wear. Your code should also handle invalid input with an appropriate message : Hint (IF statement)

#include <iostream>

using namespace std;

{

// Write what goes in here

return 0;

}

Assume this has all been given, only write what goes inside the main

Solutions

Expert Solution

Code:

#include <iostream>
using namespace std;

int main()
{
    double temp;
    cout<<"Enter temperature in Fahrenheit: ";  //get temperature from user 
    cin>>temp;
    
    if(temp <= 28)                //check temperature is 28 or less than 28
        cout<<"\nIt is freezing out, wear a winter coat";
    else if(temp >=29 && temp <= 49)       //check temperature in between 29-49
        cout<<"\nIt is fairly cold, wear a jacket";
    else if(temp >=50 && temp <= 78)       //check temperature in between 50-78
        cout<<"\nWeather is nice out, wear whatever";
    else if(temp >=79 && temp <= 100)      //check temperature in between 79-100
        cout<<"\nIt’s piping hot out, keep it light";
    else
        cout<<"\nInvalid temperature";
    
    return 0;
}

Output:


Related Solutions

1- 25 28 24 21 28 26 23 22 29 21 29 24 22 25 26...
1- 25 28 24 21 28 26 23 22 29 21 29 24 22 25 26 18 27 26 29 23 21 26 27 21 25 27 24 29 22 25 24 24 21 29 22 25 21 22 22 25 22 25 Calculate a) arithmetic mean and b) standard deviation of the sample. A) b) - Represent a classified frequency table. Answer the following questions in this table with column calculations. Calculate a) arithmetic mean, b) quadratic mean, c)...
A survey of 490 women revealed that 49​% wear flat shoes to work. a. Use this...
A survey of 490 women revealed that 49​% wear flat shoes to work. a. Use this sample information to develop a 95​% confidence interval for the population proportion of women who wear flat shoes to work. b. Suppose that the people who administered this survey now wish to estimate the proportion of women who wear athletic shoes to work with a margin of error of 0.01 with 99​% confidence. Determine the sample size required.
Percentages: A. Mr. Rios saved $ 49 on a television by buying it with a 28%...
Percentages: A. Mr. Rios saved $ 49 on a television by buying it with a 28% discount on the regular price. What was the regular price of the TV? B.The insurance company “Fénix” reported that in one month there were 122 claims. Thirty-seven of the claims were against car insurance. What percent of the claims were against car insurance?
Among the contestants in a competition are 49 women and 29 men. If 5 winners are...
Among the contestants in a competition are 49 women and 29 men. If 5 winners are selected, what is the probability that they are all women?
Salaries of men and women Woman Man 26 29 28 31 30 33 32 29 34...
Salaries of men and women Woman Man 26 29 28 31 30 33 32 29 34 33 48 56 52 54 22 28 27 33 You are trying to determine whether male and female Central Bank employees, having equal qualifications, receive different salaries. The data contain the salaries (in thousands of dollars) for 9 male and 9 female employees. Assume salaries are normally distributed. a. Assume that each row of data represents paired observations, and using alpha=0.05, can you conclude...
According to Cunningham (2011: 28-29), there are serious consequences for market failure by a nation, and...
According to Cunningham (2011: 28-29), there are serious consequences for market failure by a nation, and particularly in a small and endowed country like Sierra Leone. Discuss 5 of those consequences that can arise due to market failure.                                                             Discuss 5 recommendation as how the government of Sierra can overcome with market failure                                                                                                                      Why is it often suggested that imperfect information will result in a misallocation of resources? How can such a misallocation be avoided?                                           What is the another term...
According to Cunningham (2011: 28-29), there are serious consequences for market failure by a nation, and...
According to Cunningham (2011: 28-29), there are serious consequences for market failure by a nation, and particularly in a small and endowed country like Sierra Leone. Discuss 5 of those consequences that can arise due to market failure.                                                            
The score of a course out of 100 in Winter of 10 students are 48, 92,...
The score of a course out of 100 in Winter of 10 students are 48, 92, 47, 44, 94, 18, 95, 67, 74, 64 a. Calculate Q1, Q3 and IQR of the data. b. Find the mean, median and standard deviation c. Determine whether the smallest value of this data set is an outlier. d. Comment the shape of the distribution.
1.a. In a survey carried out at a famous water park, 28 children out of a...
1.a. In a survey carried out at a famous water park, 28 children out of a random sample of 80 said that they used the water slide regularly. Find a 95 % confidence interval for the true proportion of all children at the water park who uses the water slide regularly. [4] b. The owner of the water park found that 45 children out of a random sample of 100 said that they used the pool regularly. Find a 98%...
2. On a winter day, suppose your breath has T = 30°C with Td = 28°C,...
2. On a winter day, suppose your breath has T = 30°C with Td = 28°C, and it mixes with the ambient air of temperature T = –10°C and Td = –11°C. Will you see your breath? Assume you are at sea level, and that your breath and the environment mix in proportions of (breath : environment): a. 1:9 b. 2:8 c. 3:7 d. 4:6
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT