I have to have a looping code that does what the first part with the choices does and it was working until i moved onto adding the loop for the specific date part. If someone could help that would be amazing.
#include <cstdlib>
#include <iostream>
#include <string>
usingnamespace std;
int main(int argc, char *argv[])
{
string FirstLine="";
//need an int variable
int choicevariable = 0;
cout << "Welcome to The Time Machine" << endl << endl;
cout << "What is your Name?";
getline(cin, FirstLine);
//display user's name
cout << "HI " << FirstLine << endl << endl;
cout << "Select an option to get started:" << endl;
// i get stuck trying to figure out how to loop this part i know what parts i have to loop i am just not sure how.
while (choicevariable < 1 || choicevariable > 3)
{
cout << "1. Enter a Specific Date" << endl;
cout << "2. Select a Time Period" << endl;
cout << "3. Wildcard - I'm Feeling Lucky" << endl << endl;
//get the user's choice using your int variable and cin
cout << "Enter your choice: ";
cin >> choicevariable;
cin.clear();
cin.ignore(100, '\n');
}
//display thier choice
cout << "#" << choicevariable << endl;
if (choicevariable == 1)
while (choicevariable < 1 || choicevariable > 12)
{
cout << "What is the Month?" << endl;
int Month = 0;
cin >> Month;
while (choicevariable < 1 || choicevariable > 7)
cout << "What is the Day?" << endl;
int Day = 0;
cin >> Day;
int Year = 0;
cout << "What is the Year?" << endl;
if(!(cin >> Year)){
cin >> Year;
cout << " Ok, We will send you to" << endl;
cout << "Ending Program";
cin.clear();
cin.ignore(100, '\n');
}
if (choicevariable == 2)
{
int timePeriod;
cout << "Choice from one of the time periods:" << endl << endl;
cout << "1. Prehistoric Dinosaur Era" << endl;
cout << "2. Pirate Era" << endl;
cout << "3. Five Days ago" << endl;
cout << "4. Mideval" << endl;
cin >> timePeriod;
cout << " Ok, We will take you to" << timePeriod << endl;
cout << "Ending Program";
}
if (choicevariable == 3)
{
cout << "Ok, I'll choose where to send you" << endl;
}
elseif (choicevariable > 3)
cout << "Choice Not Valid" << endl;
cout << "Ending Program" << endl;
system("PAUSE");
return EXIT_SUCCESS;