Question

C++ Help. Any help is appreciated, thank you very much! Write a C++ program that asks...

C++ Help. Any help is appreciated, thank you very much!

Write a C++ program that asks the user for the month of the year (as a number), and prints

  • “Happy Winter” if it is strictly before 3 or strictly larger than 11,
  • “Happy Spring” if it is 3 or greater, but strictly before 7, and
  • “Happy Summer” if it is 7 or greater, but strictly before 9, and
  • “Happy Fall” otherwise.

A sample run:

   Enter month (as a number):  12
   Happy Winter

   Another sample run:

   Enter month (as a number):  8
   Happy Summer

   And another run:

   Enter month (as a number):  11
   Happy Fall
0 0
Add a comment Improve this question Transcribed image text
Answer #1

Answer:

C++

#include <iostream>

using namespace std;

int main() {
int month;
cout << "Enter month (as a number): ";
cin >> month;
if (month < 3 || month > 11) {
cout << "Happy Winter" << endl;
} else if (month >= 3 && month < 7) {
cout << "Happy Spring" << endl;
} else if (month >= 7 && month < 9) {
cout << "Happy Summer" << endl;
} else {
cout << "Happy Fall" << endl;
}
return 0;
}

out put:

Kindly Upvote if Helpful :)
HOPE THIS MAY HELP YOU----------------------

------------------------------THANK YOU

Add a comment
Know the answer?
Add Answer to:
C++ Help. Any help is appreciated, thank you very much! Write a C++ program that asks...
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
  • Python help. Any help is appreciated, thank you! Write a program that asks the user for...

    Python help. Any help is appreciated, thank you! Write a program that asks the user for a CSV of collision data (see note below about obtaining reported collisions from NYC OpenData). Your program should then list the top three contributing factors for the primary vehicle of collisions "CONTRIBUTING FACTOR VEHICLE 1"in the file. A sample run: Enter CSV file name: collisionsNewYears2016.csv Top three contributing factors for collisions: Driver Inattention/Distraction 136 Unspecified 119 Following To0 Closely 37 Name: CONTRIBUTING FACTOR VEHICLE...

  • I need help solving this! help is very much appreciated! thank you ? Let y denote...

    I need help solving this! help is very much appreciated! thank you ? Let y denote the number of broken eggs in a randomly selected carton of one dozen eggs. ply) 0.60 0.20 0.15 0.04 0.01 (a) Calculate and interpretu ? (Round your answer to two (b) In the long run, for what proportion of cartons is the number of broken eggs less than decimal places). Does this surprise you? Yes NO (c) Explain why #, is not equal to...

  • Can you write with comments please. Thank you. Write a Java Program that asks the user...

    Can you write with comments please. Thank you. Write a Java Program that asks the user to enter the responses on the Console and write the responses to a text file called responses.txt (in the same directory as the program) Write another JAVA prorgram to read responses.txt file and calculate the frequency of each rating in the file and output the number and frequency in two columns (number, frequency) on the Console.

  • Can someone please help me complete this question. Any help would be very much appreciated. Thank...

    Can someone please help me complete this question. Any help would be very much appreciated. Thank you. Let x determine a random variable, and use your knowledge of probability to prepare a probability distribution A family has four children and the number of girls is recorded. (Assume an equal chance of a boy or girl for each birth.) Complete the probability distribution. P(x) 16 Type an integer or a simplified fraction.)

  • Python help! Any help is appreciated, thank you! Fill in the missing function, monthString(), in the...

    Python help! Any help is appreciated, thank you! Fill in the missing function, monthString(), in the program. The function should take number between 1 and 12 as a parameter and returns the corresponding month as a string. For example, if the parameter is 1, your function should return "January". If the parameter is 2, your function should return out "February", etc. def monthString(monthNum): """ Takes as input a number, monthNum, and returns the corresponding month name as a string. Example:...

  • Write a program that asks for 'name from the user and then asks for a number...

    Write a program that asks for 'name from the user and then asks for a number and stores the two in a dictionary [called the_dicr) as key-value pair. The program then asks if the user wants to enter more data [More data ly/n]?) and depending on user choice, either asks for another name-number pair or exits and stores the dictionary key, values in a list of tuples and prints the list Note: Ignore the case where the name is already...

  • Write a program which asks the user to enter an integer. Use switch statement to write...

    Write a program which asks the user to enter an integer. Use switch statement to write out the numeric word (such as ONE) if the user's input is 1; (see the sample run output for the usr input 2 or 3); otherwise, write OUT OF RANGE. Below are few sample runs: If the user enters a 1, the program will print: ONE TWO THREE Or, if the user enters a 2, the program will print: TWO THREE Or, if the...

  • RandomGame.cpp (2pt) Write a program that asks the user to enter his/her name. Then begin a...

    RandomGame.cpp (2pt) Write a program that asks the user to enter his/her name. Then begin a do while loop that asks the user to enter a number between 1 and 10. Have the random number generator produce a number 1 and 10. Display the user’s name and both numbers to the screen. Compare the two numbers and report if the entered number is greater than, less than, or the same as the generated number. Ask the user if he/she’d like...

  • Topics If/Else statement Description    Write a program that determines the larger of the two numbers...

    Topics If/Else statement Description    Write a program that determines the larger of the two numbers provided by the user. The program asks the user to enter a number. Then it asks the user to enter another but a different number. Then, it determines the larger of the two numbers and displays it to the user. (If the user happens to enter the two numbers the same, the program may report either of the two numbers as larger.) Requirements Do...

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