Question

If statement (c++ program) How do I write a program that prompts the user for what...

If statement (c++ program)

How do I write a program that prompts the user for what the name of the day is and reports if it is the weekend. Look at the test cases for exact formatting and language

user enters S

gets weekend

user enters t

gets weekday

0 0
Add a comment Improve this question Transcribed image text
Answer #1

CODE :

#include <iostream>
using namespace std;
int main()
{
char day;
cout<<"Enter the day(first letter of day)"<<endl;
cin>>day;
if(day=='S' || day=='s')//because weekend day starts with S letter
{
cout<<"Weekend"<<endl;
}
else
{
cout<<"weekday"<<endl;
}

return 0;
}

Sample Output :

Add a comment
Know the answer?
Add Answer to:
If statement (c++ program) How do I write a program that prompts the user for what...
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 script in MATLAB that prompts the user to do a, b, & c. a.)script...

    Write a script in MATLAB that prompts the user to do a, b, & c. a.)script that prompts the user to enter the day of the week using the input function. If the information the user enters is equal to “Saturday” or “Sunday”, display “have a nice weekend” in the Command Window. Otherwise, display “Good luck in your class lectures and your studies.” b.)script that prompts the user to input the following array by providing an example in the prompt:...

  • write a c++ program that prompts a user for a number then attempts to allocate an...

    write a c++ program that prompts a user for a number then attempts to allocate an array of as many integers as the user enters. In other words, the program might prompt the user with a line like: “How many integers would you like to allocate?” It should then allocate as many integers as the user enters. The program should then wait for the user to press enter before deleting the allocated array and quitting. We will use this time...

  • Write a C++ Program Write a program that prompts the user to input a number. The...

    Write a C++ Program Write a program that prompts the user to input a number. The program should then output the number and a message saying whether the number is positive, negative, or zero. You must insert the following comments at the beginning of your program and write our commands in the middle: Write a C++ Program: 1 Name: Your Name ID: Your ID #include <iostream> using namespace std; din main YOUR CODE HERE

  • Write a program in C++ that prompts the user to input the name of a text...

    Write a program in C++ that prompts the user to input the name of a text file and then outputs the number of words in the file. You can consider a

  • Q1 (2 pts) Shopping list Write a program that prompts a user for items on their...

    Q1 (2 pts) Shopping list Write a program that prompts a user for items on their shopping list and keeps prompting the user until they enter "Done" (make sure your program can stop even if the user enters "Done" with different cases, like "done"), then prints out the items in the list, line by line, and prints the total number of items on the shopping list. Output (after collecting items in the while loop) should look something like this: Apple...

  • c++ Write a program that prompts the user to enter a length in feet and then...

    c++ Write a program that prompts the user to enter a length in feet and then enter a length in inches and outputs the equivalent length in centimeters. If the user enters a negative number or a non-digit number, throw and handle an appropriate exception and prompt the user to enter another set of numbers. Your error message should read A non positive number is entered and allow the user to try again.

  • Write a program that prompts the user to enter an integer, n , and then n...

    Write a program that prompts the user to enter an integer, n , and then n floating point numbers. As the numbers are read, the program will calculate the average of the negative numbers. In C language.

  • Write a C program that prompts the user for an input string with all lowercase letters....

    Write a C program that prompts the user for an input string with all lowercase letters. Your program should then sort the characters in the string and print the sorted string. Assume that the string contains no spaces and has at most 30 lowercase characters. Your program should loop continually until the user enters “q” to quit.

  • please help Create a program that prompts the user for a sentence and then displays the...

    please help Create a program that prompts the user for a sentence and then displays the hash of the sentence. Refer to the textbook Chapter 5.2 and the Support Video in zyBook section 3.1 for more instruction on hashing. Program Requirements: The program should prompt the user for the "sentence" to be hashed and then compute the hash of the sentence by summing the numeric value of each letter in the sentence (use A=a=1, B=b=2 ... Z=z=26, space=31) and applying...

  • Write a Visual C# program that will input the user's name and a message. The user...

    Write a Visual C# program that will input the user's name and a message. The user will be able to choose from an option of formatting tools to change the way the message (and only the message) will look. The user can choose from bold, underline, italic, along with several different color options. All changes the user selects will be displayed in the message textbox. Once the user selects the Finish button, the two pieces of information entered by the...

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