jeudi 27 avril 2017

C++ how to allow user to choose choice

Hi i dont know how to allow the user to choose one of the choices i provided in my code and if they picked a choice that was not given then i want the program to return to the last point.

This is my code

#include <iostream>
#include <string>

using namespace std;

int main()
{

//Welcoming message with date//
cout << "Welcome to FILM Screen Cinema" << endl;


cout << endl;
cout << "ENTER STAFF/OPERATOR'S NAME: ";
string name;
cin >> name;

cout << endl;
cout << "ENTER DATE:";
string date;
cin >> date;

cout << endl;
cout << "CHOOSE A MOVIE THAT IS SCREENING TODAY:" << endl;
cout << "[1] Deadpool" << endl << "[2] Goosebumps" <<endl;
string input;
cin >> input;


}

Where it says choose a movie, i want the user to type either 1 or 2 for the choices but if they type any other number then it should say invalid and allow them to type 1 or 2 again. Thank you in advance.

Aucun commentaire:

Enregistrer un commentaire