Answer to Question #130539 in C++ for Zaib Mk

Question #130539
Develop the program that uses the following categories of movies ?

A for Adventure movies
C for Comedy movies
F for family movies
H for Horror movies
S for Science and function movies
1
Expert's answer
2020-08-24T16:29:58-0400
using namespace std;


#include <iostream>
#include <string>


int main()
{
	char choice;
	string category;
	while (true)
	{
		cout << "Enter the letter of the movie category: ";
		getline(cin, category);
		if (!category.empty())
		{
			choice = category.front();
			switch (choice)
			{
			case 'A':
				category = "Adventure";
				break;
			case 'C':
				category = "Comedy";
				break;
			case 'F':
				category = "Family";
				break;
			case 'H':
				category = "Horror";
				break;
			case 'S':
				category = "Science and Function";
				break;
			default:
				cout << "There is no category for this char. Categories are available under the chars A, C, F, H and S. Please re-enter.\n\n";
				continue;
			}
			cout << "You have chosen the " << category << " movies category.\n\n";
		}
		else
		{
			cout << "Empty input. Please re-enter.\n\n";
		}
	}
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS