7. Program inputs code for movie type and display its category.

Chapter 5: 

Conditional Structures

Programming Exercise

Problem # 7:

Write a 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 Fiction movies
The program inputs code for movie type and display its category. For examples if the user enters H, it displays "Horror Movies". The program should also display a menu of movie categories.

Solution:

#include<iostream>
#include<conio.h>
using namespace std;
int main ()
{
    char c;
    cout<<"Menu for movie categories:\nA for Adventure movies\nC for Comedy movies\nF for Family movies\nH for Horror movies\nS for Science fiction movies";
    cout<<"\nEnter your code:";
    cin>>c;
    switch(c)
    {
        case 'A':
            cout<<"\nAdventure movies.";
            break;
        case'C':
            cout<<"\nComedy movies.";
            break;
        case 'F':
            cout<<"\nFamily movies.";
            break;
        case 'H':
            cout<<"\nHorror movies.";
            break;
        case 'S':
            cout<<"\nScience fiction movies.";
            break;
        default:
            cout<<"\nInvalid input.";
          
    }
    return 0;
}


Let me know in the comment section if you have any question.

Previous Post:
6. Program that accepts the code number as an input and display the correct disk drive manufacture.

Comments