Question

30 (40 points) Write the complete program in c++ that will input a temperature and indicate whether the weather is appropriat
0 0
Add a comment Improve this question Transcribed image text
Answer #1
#include <iostream>

using namespace std;

int main() {
    double temp;
    cout << "Enter temperature: ";
    cin >> temp;

    if (temp >= 80) {
        cout << "swimming" << endl;
    } else if (temp > 40) {
        cout << "golf" << endl;
    } else if (temp >= 20) {
        cout << "skiing" << endl;
    } else {
        cout << "invalid temperature" << endl;
    }
    return 0;
}
Add a comment
Know the answer?
Add Answer to:
30 (40 points) Write the complete program in c++ that will input a temperature and indicate...
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. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • WRITE A COMPLETE PROGRAM IN C++ A. Ask users to input two positive integers a and...

    WRITE A COMPLETE PROGRAM IN C++ A. Ask users to input two positive integers a and b (a < b). You need to do error checking in this stage to make sure the input is correct. For example, a = 1, b = 50. B. Write a separate function, isEven() to list all even within [a, b] inclusive. C. n the main function, print a, b and the list of even numbers.

  • Complete ACTIVITY program using the following specification: Write a C++ program that displays a suggested activity...

    Complete ACTIVITY program using the following specification: Write a C++ program that displays a suggested activity based on the outdoor temperature (in fahrenheit) and whether or not it is raining/snowing. Use the following table for suggested activities. Show both with nested loops and with logical operators.( WRITE THE CODE VERY CLEARY SHOWING ALL THE STEPS) Temperature Raining/Snowing Activity >=80 no beach volleyball >=80 yes movie <80 and >=32 no running <80 and >=32 yes racquetball <32 no ice fishing <32...

  • In C programming Write a program that displays the appropriate prompt to input 5 scores. Once...

    In C programming Write a program that displays the appropriate prompt to input 5 scores. Once the user inputs the five integer values, your program calculates and prints the average. You do not need to declare five different variables, think of how you can get away with a single variable. The second part of this program will print A if the average of these 5 numbers is greater than or equal to 90 but less than 100, B if greater...

  • Write a program that takes a file as input and checks whether or not the content...

    Write a program that takes a file as input and checks whether or not the content of the file is balanced. In the context of this assignment “balanced” means that your program will check to make sure that for each left bracket there is a closing right bracket. Examples:             [ ( ) ] { } à balanced.             [ ( ] ) { } à unbalanced. Here is the list of brackets/braces that program must support: (: left parentheses...

  • This program should be written in C Thoroughly following the Code Conventions, write an efficient program,...

    This program should be written in C Thoroughly following the Code Conventions, write an efficient program, which ask the user for their numeric grade, and determines and displays the equivalent letter grade, based on the following information: Use appropriate data types and initialize the variables correctly Use the following grading scale: A: 90 - 100 B: 80 - < 90 C: 70 - < 80 D: 60 - < 70 F: 0 - < 60 If the input is invalid,...

  • Question 1 The following program asks the user for the current temperature (in Fahrenheit). Provide a...

    Question 1 The following program asks the user for the current temperature (in Fahrenheit). Provide a total of 7 valid test cases (one for each message). Do not provide invalid test cases. Add a series of if statements (if with multiple alternatives i.e. if/else if/else) so that one of the following messages is printed based on the temperature value: Temperature (F) Message >90 “Go swimming.” <=90, >80 “Turn on air conditioning.” <=80, >70 “Do nothing.” <=70, >55 “Turn on heat.”...

  • JAVA 2. (8 points) Write a code segment which prompts the user to enter the price...

    JAVA 2. (8 points) Write a code segment which prompts the user to enter the price of a tour and receives input from the user. A valid tour price is between $52.95 and $259.95, inclusive. Your program should continue to repeat until a valid tour price has been entered. If the user enters an invalid price, display a message describing why the input is invalid. You may assume that the user only enters a real number. The user will not...

  • In C:Write a program that can determine whether a user input is a binary number or...

    In C:Write a program that can determine whether a user input is a binary number or not. (1, 2, 3, 8, 13) Write a program that accomplishes all of the following: Greets the user and informs them that the program will determine whether an input from the user is a valid binary number or not (e.g., consisting of only 0’s and/or 1’s). Accept an integer input from the user. Assume that the user provides a valid numeric input that will...

  • Write a complete C program that does the following: . o Declare a and b as...

    Write a complete C program that does the following: . o Declare a and b as character variables. Initialize a to this value: 127 o Declare c as an unsigned character variable o Multiply a by 2 and store the result in variable b. o Multiple a by 2 and store the result in variable c. Print the values of a, b, and c. Use the %d specifier in each case. Declare d as an integer variable. Initialize d to...

  • 1. Write a complete C++ program named “CheckAmount” that accepts command line arguments. It checks whether...

    1. Write a complete C++ program named “CheckAmount” that accepts command line arguments. It checks whether there is a command line argument of “-amount” followed by an amount number. It will print out that number amount. For all other cases, it will print out -1. For example, if you run this program with correct arguments as follows, it will print out 1.99, 0.75 and 1.1 respectively CheckAmount -amount 1.99 CheckAmount -help -amount 0.75 CheckAmount -help -check -amount 1.1 -verbose And...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT