6 Replies - 783 Views - Last Post: 14 March 2012 - 06:38 AM Rate Topic: -----

#1 kioam   User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 3
  • Joined: 13-March 12

Program not working as intended, no syntax error from compiler

Posted 13 March 2012 - 07:51 PM

Hi,
I am just beginning programming and made an attempt to make this text-based "RPG" game. My compiler is not giving me any errors. Basically, this game starts with a main menu where you can see the rules, play the game, or exit. Everything works fine if I choose to play the game and then from the next menu in the game choose option 1. If I choose any other option it simply displays the main menu all over again. Also, I wrote for the program to display a goodbye message when you choose to exit the game, but this message isn't showing up :whatsthat:

I'm really confused as to why the game works like a charm when choosing option 1 after pressing "play" but doesn't work at all otherwise. From what I can tell my code all lines up the same so I'm really not sure what I've done wrong.

:helpsmilie:

Here is the (admittedly long) code:

/* project1.cpp
March 13, 2012
This is a text-based RPG named John's Zombies
*/

#include <iostream>
#include <fstream>
#include <ctime>
#include <string>

using namespace std;

int main()
{
	//declare and initialize variables
	int mainChoice = 0, introChoice = 0, locChoice = 0, combatChoice = 0,finalChoice = 0; 		int score = 0, cRandom = 0, coRandom = 0, highscore = 0;
	string firstName, highName;

	//declare file pointer for input
	ifstream infile;

	//declare file pointer for output
	ofstream outfile;

	//Intro
	cout<<"WELCOME TO JOHN'S ZOMBIES!"<<endl<<endl;
	
	//prompt for firstName
	cout<<"Enter your first name: ";
	cin>>firstName;
	cout<<endl;

	//begin do while loop for main menu
	do
	{
	//display main menu
	cout<<"1) See Rules\n2) Play Game\n3) Quit\n";

	//prompt for mainChoice
	cout<<"Enter your choice: ";
	cin>>mainChoice;
	

	//if statements for main menu choice
	if (mainChoice == 1)
		{
		//display rules and story
		cout<<"The plague is upon us. Slowly but surely, all of the people of the great Mother Land are becoming infected and turned into undead. Ruthless, disgusting, and viscious creatures - these 'zombies' roam through villages and infect men, women, and children one by one. Their army is only getting stronger. Your story begins here, hero... you WILL be a legend. Alive or not, well, that depends entirely on your choices. Remember: you cannot control it all; sometimes fate must choose for you.\n\nRead through the story of the game and make important 	decisions when prompted. Your score will be based on your decisions, but some of your score will be out of your hands! Tread lightly.."<<endl<<endl;
		
		}
	else if (mainChoice == 2)
		{
		//begin game

		//initialize counter
		score = 0;

		//display intro text
		cout<<"You hear a young woman screaming, 'The zombie plague is coming! THE ZOMBIE PLAGUE IS COMING!!!' Having heard the news earlier, you decide to step up and take on the undead yourself. You are aware it won't be an easy task, but you pick your head up and approach the woman. 'Can you tell me more about the plague?' you ask. She doesn't seem to pay you any mind. Try telling her a little more about yourself.."<<endl<<endl;

		//display menu
		cout<<"1) I am a great warrior and I will destroy the undead one by one with brute force.\n2) I am a powerful mage, ready to harness the arcane energies to defeat the undead.\n3) I am a priest. I will use my holy fire to smite the enemy into oblivion.\n4) I am a skilled assassin. With my expertise in traps and poisons, I will defeat the undead."<<endl;

		do
		{
		//prompt for introChoice
		cout<<"Enter your choice: ";
		cin>>introChoice;
		
		if (introChoice < 1 || introChoice > 4)
			{
			//display invalid
			cout<<"Invalid. Please enter 1, 2, 3, or 4."<<endl<<endl;
			}
		}
		while (introChoice < 1 || introChoice > 4); 
		
		//calculate points for introChoice (RANDOM)
		//seed random number generator
		srand(time(NULL));
		//generate a random number from 1-300
		cRandom = rand()%300 + 1; 
		
		score += cRandom;

		//if statements for introChoice menu
		if (introChoice == 1)
		{
		//display warrior locChoice text
		cout<<"Quickly running her eyes over your body, the woman scoffed. 'Right. Of course. Well, the plague has spread to several surrounding villages. You can't be in four places at once, but if you really want to help, there are roads leading	to each village near the north, south, east, and west exits of our town. Good luck, warrior... you're going to need it.'"<<endl<<endl;

		//display warrior locChoice menu
		cout<<"1) Go North to Lenville - there are currently 300 zombies and counting.\n2) Go South to Medlania - there are currently 1,000 zombies and counting.\n3) Go East to Staland - there are currently 100 zombies and counting.\n4) Go west to Cherak - there are currently 450 zombies and counting."<<endl<<endl;

		do
		{
		//prompt for locChoice
		cout<<"Enter your choice: ";
		cin>>locChoice;
		
		if (locChoice < 1 || locChoice > 4)
			{
			//display invalid
			cout<<"Invalid. Please enter 1, 2 , 3 or 4."<<endl<<endl;
			}
		}
		while (locChoice < 1 || locChoice > 4);

		//if statements for locChoice
		if (locChoice == 1)
			{
			score += 50;	
	
			//display north combatChoice text
			cout<<"Upon your arrival in Lenville, you notice a foul stench violate your sense of smell and begin to evaluate your grim surroundings. Slowly, you begin to examine the homes scattered around the village, your heavy axe ready for combat. After searching for almost an hour, you begin to grow suspicious. Just as you turn to leave the village, you hear a rumble of low growling and grunting. The zombies approach you, dragging their feet and bodies across the dirt. You know what you have to do."<<endl<<endl;

			//display north combatChoice menu
			cout<<"1) Step towards the horde of undead calmly and strike first.\n2) Charge into the group hoping for the best.\n3) Take a defensive approach and wait for them to come before attacking.\n4) RUN FOR IT! You can't do this. Just try not to drown in your own tears."<<endl;

			do
			{
			//prompt for combatChoice
			cout<<"Enter your choice: ";
			cin>>combatChoice;
			
			if (combatChoice < 1 || combatChoice > 4)
				{
				//display invalid
				cout<<"Invalid. Please enter 1, 2, 3, or 4."<<endl<<endl;
				}
			}
			while (combatChoice < 1 || combatChoice > 4);


			//calculate combatChoice points(RANDOM)
			//seed random number generator
			srand(time(NULL));
			//generate a random number from 1-100
			cRandom = rand()%100 + 1; 

			score += coRandom;


			//if statements for combatChoice menu
			if (combatChoice >= 1 && combatChoice <= 4)
				{
				//display finalChoice text
				cout<<"Covered in blood, sweat, and other unidentifiable liquids, you limp back to your own village. An unbearable pain in your thigh seems to be worsening. As you enter the familiar boundaries of your home, you begin searching for your family. You begin to panic, eyes darting around, when nobody is there to greet you. Something is off. Finally, you spot your wife. There's something different about her. 'John...braiiiiiiiins....' she groans. Your eyes well up with tears, it's time to make your final choice."<<endl<<endl;

				//display finalChoice menu
				cout<<"1) Embrace your wife and let her infect you with the plague. Zombie life can't be that bad.\n2) Use all of your remaining strength to kill her. You must protect the greater good.\n3) Surrender yourself to death.\n4) Limp away as fast as you can."<<endl;


				do
				{
				//prompt for finalChoice
				cout<<"Enter your choice: ";
				cin>>finalChoice;
				
				if (finalChoice < 1 || finalChoice > 4)
					{
					//display invalid
					cout<<"Invalid. Please enter 1, 2, 3, or 4."<<endl<<endl;
					}
				}
				while (finalChoice < 1 || finalChoice > 4);
			
				//if statements for finalChoice
				
				if (finalChoice == 1)
					score += 100;

				else if (finalChoice == 2)
					score += 250;
			
				else if (finalChoice == 3)
					score += 50;
				
				else if (finalChoice == 4)
					score += 20;

				else
					//display invalid
					cout<<"Invalid. Please choose 1, 2, 3, or 4."<<endl;
				
				
				
			//display final score
			cout<<"Your final score is: "<<score<<"."<<endl<<endl;
			//open file "highscore.txt" for input
			infile.open("highscore.txt", ios::in);	

			//read in data
			//read in highName
			getline(infile, highName);
			//read in highscore
			infile>>highscore;
			
			
			if (score > highscore)
				{				
				//Display congrats
				cout<<"CONGRATULATIONS!! YOU HAVE BEATEN THE PREVIOUS HIGHSCORE OF "<<highscore<<"!!"<<endl<<endl;
				//Replace old highscore with new highscore
				infile.close();
				
				outfile.open("highscore.txt", ios::out);
				outfile<<firstName<<" "<<score;	

				outfile.close();
				
				}
			else
				//display sorry
				cout<<"Sorry! You didn't beat the highscore. Keep trying!"<<endl<<endl;
			
			
			}
		else if (locChoice == 2)
			{
			score += 250;	

			//display south combatChoice text
			cout<<"Upon your arrival in Medlania, you notice a foul stench violate your sense of smell and begin to evaluate your grim surroundings. Slowly, you begin to examine the homes scattered around the village, your heavy axe ready for combat. After searching for almost an hour, you begin to grow suspicious. Just as you turn to leave the village, you hear a rumble of low growling and grunting. The zombies approach you, dragging their feet and bodies across the dirt. You know what you have to do."<<endl<<endl;

			//display south combatChoice menu
			cout<<"1) Step towards the horde of undead calmly and strike first.\n2) Charge into the group hoping for the best.\n3) Take a defensive approach and wait for them to come before attacking.\n4) RUN FOR IT! You can't do this. Just try not to drown in your own tears."<<endl;

			do
			{
			//prompt for combatChoice
			cout<<"Enter your choice: ";
			cin>>combatChoice;
					
			if (combatChoice < 1 || combatChoice > 4)
				{
				//display invalid
				cout<<"Invalid. Please enter 1, 2, 3, or 4."<<endl<<endl;
				}
			}
			while (combatChoice < 1 || combatChoice > 4);

			//calculate combatChoice points(RANDOM)
			//seed random number generator
			srand(time(NULL));
			//generate a random number from 1-100
			cRandom = rand()%100 + 1; 

			score += coRandom;
			
			//if statements for combatChoice menu
			if (combatChoice >= 1 && combatChoice <= 4)
				//display finalChoice text
				cout<<"Covered in blood, sweat, and other unidentifiable liquids, you limp back to your own village. An unbearable pain in your thigh seems to be worsening. As you enter the familiar boundaries of your home, you begin searching for your family. You begin to panic, eyes darting around, when nobody is there to greet you. Something is off. Finally, you spot your wife. There's something different about her. 'John...braiiiiiiiins....' she groans. Your eyes well up with tears, it's time to make your final choice."<<endl<<endl;

				//display finalChoice menu
				cout<<"1) Embrace your wife and let her infect you with the plague. Zombie life can't be that bad.\n2) Use all of your remaining strength to kill her. You must protect the greater good.\n3) Surrender yourself to death.\n4) Limp away as fast as you can."<<endl;


				do
				{
				//prompt for finalChoice
				cout<<"Enter your choice: ";
				cin>>finalChoice;
				if (finalChoice < 1 || finalChoice > 4)
					{
					//display invalid
					cout<<"Invalid. Please enter 1, 2, 3, or 4."<<endl<<endl;
					}
				}
				while (finalChoice < 1 || finalChoice > 4);

				//if statements for finalChoice
					if (finalChoice == 1)
						score += 100;

					else if (finalChoice == 2)
						score += 250;
			
					else if (finalChoice == 3)
						score += 50;
				
					else if (finalChoice == 4)
						score += 20;

					else
					//display invalid
					cout<<"Invalid. Please enter 1, 2, 3, or 4."<<endl<<endl;


				//display final score
				cout<<"Your final score is: "<<score<<"."<<endl<<endl;
				//open file "highscore.txt" for input
				infile.open("highscore.txt", ios::in);	

				//read in data
				//read in highName
				getline(infile, highName);
				//read in highscore
				infile>>highscore;

				if (score > highscore)
					{
					//Display congrats
					cout<<"CONGRATULATIONS!! YOU HAVE BEATEN THE PREVIOUS HIGHSCORE OF"<<highscore<<"!!"<<endl<<endl;
					//Replace old highscore with new highscore
					infile.close();

					outfile.open("highscore.txt", ios::out);
					
					outfile<<firstName<<" "<<score;
					
					outfile.close();
					}
				else
					{
					//display sorry
					cout<<"Sorry! You didn't beat the highscore! Keep trying!"<<endl<<endl;
					}

			
			}
			}
		else if (locChoice == 3)
			{
			score += 20;

			//display east combatChoice text
			cout<<"Upon your arrival in Staland, you notice a foul stench violate your sense of smell and begin to evaluate your grim surroundings. Slowly, you begin to examine the homes scattered around the village, your heavy axe ready for combat. After searching for almost an hour, you begin to grow suspicious. Just as you turn to leave the village, you hear a rumble of low growling and grunting. The zombies approach you, dragging their feet and bodies across the dirt. You know what you have to do."<<endl<<endl;

			//display east combatChoice menu
			cout<<"1) Step towards the horde of undead calmly and strike first.\n2) Charge into the group hoping for the best.\n3) Take a defensive approach and wait for them to come before attacking.\n4) RUN FOR IT! You can't do this. Just try not to drown in your own tears."<<endl;


			do
			{
			//prompt for combatChoice
			cout<<"Enter your choice: ";
			cin>>combatChoice;
			if (combatChoice < 1 || combatChoice > 4)
				{
				//display invalid
				cout<<"Invalid. Please enter 1, 2, 3, or 4."<<endl<<endl;
				}
			}
			while (combatChoice < 1 || combatChoice > 4);

			//calculate combatChoice points(RANDOM)
			//seed random number generator
			srand(time(NULL));
			//generate random number 1-100
			coRandom = rand()%100 + 1;  

			score += coRandom;
			
			//if statements for combatChoice menu
			if (combatChoice >= 1 && combatChoice <= 4)
				
				//display finalChoice text
				cout<<"Covered in blood, sweat, and other unidentifiable liquids, you limp back to your own village. An unbearable pain in your thigh seems to be worsening. As you enter the familiar boundaries of your home, you begin searching for your family. You begin to panic, eyes darting around, when nobody is there to greet you. Something is off. Finally, you spot your wife. There's something different about her. 'John...braiiiiiiiins....' she groans. Your eyes well up with tears, it's time to make your final choice."<<endl<<endl;

				//display finalChoice menu
				cout<<"1) Embrace your wife and let her infect you with the plague. Zombie life can't be that bad.\n2) Use all of your remaining strength to kill her. You must protect the greater good.\n3) Surrender yourself to death.\n4) Limp away as fast as you can."<<endl;


				do
				{
				//prompt for finalChoice
				cout<<"Enter your choice: ";
				cin>>finalChoice;
				
				if (finalChoice < 1 || finalChoice > 4);
					{
					//display invalid
					cout<<"Invalid. Please enter 1, 2, 3, or 4."<<endl<<endl;
					}
				}
				while (finalChoice < 1 || finalChoice > 4);
				
				
				//if statements for finalChoice
					if (finalChoice == 1)
						score += 100;

					else if (finalChoice == 2)
						score += 250;
			
					else if (finalChoice == 3)
						score += 50;
				
					else if (finalChoice == 4)
						score += 20;


				//display final score
				cout<<"Your final score is "<<score<<"."<<endl<<endl;

				//open file "highscore.txt" for input
				infile.open("highscore.txt", ios::in);

				//read in data
				//read in highName
				getline(infile, highName);
				//read in highscore
				infile>>highscore;	
				
				if (score > highscore)
					{
					//Display congrats
					cout<<"CONGRATULATIONS!! YOU HAVE BEATEN THE PREVIOUS HIGH SCORE OF "<<score<<"!!"<<endl<<endl;
					//Replace old highscore with new highscore
					infile.close();

					outfile.open("highscore.txt", ios::out);
					outfile<<firstName<<" "<<score;



					outfile.close();
					}
				else
					//display sorry
					cout<<"Sorry! You didn't beat the highscore! Keep trying!"<<endl<<endl;

			
			}
			}
		else if (locChoice == 4)
			{
			score += 100;

			//display west combatChoice text
			cout<<"Upon your arrival in Cherak, you notice a foul stench violate your sense of smell and begin to evaluate your grim surroundings. Slowly, you begin to examine the homes scattered around the village, your heavy axe ready for combat. After searching for almost an hour, you begin to grow suspicious. Just as you turn to leave the village, you hear a rumble of low growling and grunting. The zombies approach you, dragging their feet and bodies across the dirt. You know what you have to do."<<endl<<endl;

			//display west combatChoice menu
			cout<<"1) Step towards the horde of undead calmly and strike first.\n2) Charge into the group hoping for the best.\n3) Take a defensive approach and wait for them to come before attacking.\n4) RUN FOR IT! You can't do this. Just try not to drown in your own tears."<<endl;


			do
			{
			//prompt for combatChoice
			cout<<"Enter your choice: ";
			cin>>combatChoice;
			
			if (combatChoice < 1 || combatChoice > 4)
				{
				//display invalid
				cout<<"Invalid. Please enter 1, 2, 3, or 4."<<endl<<endl;
				}
			}
			while (combatChoice < 1 || combatChoice > 4);

			//calculate combatChoice points(RANDOM)
			//seed random number generator
			srand(time(NULL));
			//generate random number 1-100
			coRandom = rand()%100 + 1;

			score += coRandom;
			
			//if statements for combatChoice menu
			if (combatChoice >= 1 && combatChoice <= 4)
				//display finalChoice text
				cout<<"Covered in blood, sweat, and other unidentifiable liquids, you limp back to your own village. An unbearable pain in your thigh seems to be worsening. As you enter the familiar boundaries of your home, you begin searching for your family. You begin to panic, eyes darting around, when nobody is there to greet you. Something is off. Finally, you spot your wife. There's something different about her. 'John...braiiiiiiiins....' she groans. Your eyes well up with tears, it's time to make your final choice."<<endl<<endl;

				//display finalChoice menu
				cout<<"1) Embrace your wife and let her infect you with the plague. Zombie life can't be that bad.\n2) Use all of your remaining strength to kill her. You must protect the greater good.\n3) Surrender yourself to death.\n4) Limp away as fast as you can."<<endl;


				do
				{
				//prompt for finalChoice
				cout<<"Enter your choice: ";
				cin>>finalChoice;
				
				if (finalChoice < 1 || finalChoice > 4)
					{
					//display invalid
					cout<<"Invalid. Please enter 1, 2, 3, or 4."<<endl<<endl;
					}
				}
				while (finalChoice < 1 || finalChoice > 4);

				//if statements for finalChoice
					if (finalChoice == 1)
						score += 100;

					else if (finalChoice == 2)
						score += 250;
			
					else if (finalChoice == 3)
						score += 50;
				
					else if (finalChoice == 4)
						score += 20;

					else
						//display invalid
						cout<<"Invalid. Please enter 1, 2, 3, or 4."<<endl<<endl;

				//display final score
				cout<<"Your final score is "<<score<<"."<<endl<<endl;
				
				//open file "highscore.txt" for input
				infile.open("highscore.txt", ios::in);

				//read in data
				//read in highName
				getline(infile, highName);
				//read in highscore
				cin>>highscore;

				if (score > highscore)
					{
					//Display congrats
					cout<<"CONGRATULATIONS!! YOU HAVE BEATEN THE PREVIOUS HIGHSCORE OF "<<highscore<<"!!"<<endl<<endl;
					//Replace old highscore with new highscore
					infile.close();
				
					outfile.open("highscore.txt", ios::out);
					
					outfile<<firstName<<" "<<score;


					outfile.close();
					}
				else 
					//display sorry
					cout<<"Sorry! You didn't beat the highscore. Keep trying."<<endl<<endl;

			
		}
		}
	else if (introChoice == 2)
		{
		//display mage locChoice text
		cout<<"Quickly running her eyes over your body, the woman scoffed. 'Right. Of course. Well, the plague has spread to several surrounding villages. You can't be in four places at once, but if you really want to help, there are roads leading	to each village near the north, south, east, and west exits of our town. Good luck, mage... you're going to need it.'"<<endl<<endl;

		//display mage locChoice menu
		cout<<"1) Go North to Lenville - there are currently 300 zombies and counting.\n2) Go South to Medlania - there are currently 1,000 zombies and counting.\n3) Go East to Staland - there are currently 100 zombies and counting.\n4) Go west to Cherak - there are currently 450 zombies and counting."<<endl;

		do
		{
		//prompt for locChoice
		cout<<"Enter your choice: ";
		cin>>locChoice;
		
		if (locChoice < 1 || locChoice > 4)
			{
			//display invalid
			cout<<"Invalid. Please enter 1, 2, 3, or 4."<<endl<<endl;
			}
		}
		while (locChoice < 1 || locChoice > 4);


		//if statements for locChoice
		if (locChoice == 1)
			{
			score += 50;

			//display north combatChoice text
			cout<<"Upon your arrival in Lenville, you notice a foul stench violate your sense of smell and begin to evaluate your grim surroundings. Slowly, you begin to examine the homes scattered around the village, your arcane powers ready for combat. After searching for almost an hour, you begin to grow suspicious. Just as you turn to leave the village, you hear a rumble of low growling and grunting. The zombies approach you, dragging their feet and bodies across the dirt. You know what you have to do."<<endl<<endl;

			//display north combatChoice menu
			cout<<"1) Step towards the horde of undead calmly and strike first.\n2) Charge into the group hoping for the best.\n3) Take a defensive approach and wait for them to come before attacking.\n4) RUN FOR IT! You can't do this. Just try not to drown in your own tears."<<endl;
	
			do
			{
			//prompt for combatChoice
			cout<<"Enter your choice: ";
			cin>>combatChoice;
			if (combatChoice < 1 || combatChoice > 4)
				{
				//display invalid
				cout<<"Invalid. Please enter 1, 2, 3, or 4."<<endl<<endl;
				}
			}
			while (combatChoice < 1 || combatChoice > 4);

			//calculate combatChoice points(RANDOM)
			//seed random number generator
			srand(time(NULL));
			//generate random number 1-100
			coRandom = rand()%100 + 1;

			score += coRandom;
			
			//if statements for combatChoice menu
			if (combatChoice >= 1 && combatChoice <= 4)
				{
				//display finalChoice text
				cout<<"Covered in blood, sweat, and other unidentifiable liquids, you 	limp back to your own village. An unbearable pain in your thigh seems to be worsening. As you enter the familiar boundaries of your home, you begin searching for your family. You begin to panic, eyes darting around, when nobody is there to greet you. Something is off. Finally, you spot your wife. There's something different about her. 'John...braiiiiiiiins....' she groans. Your eyes well up with tears, it's time to make your final choice."<<endl<<endl;

				//display finalChoice menu
				cout<<"1) Embrace your wife and let her infect you with the plague. Zombie life can't be that bad.\n2) Use all of your remaining strength to kill her. You must protect the greater good.\n3) Surrender yourself to death.\n4) Limp away as fast as you can."<<endl;


				do
				{
				//prompt for finalChoice
				cout<<"Enter your choice: ";
				cin>>finalChoice;
				
				if (finalChoice < 1 || finalChoice > 4)
					{
					//display invalid
					cout<<"Invalid. Please enter 1, 2, 3, or 4."<<endl<<endl;
					}
				}
				while (finalChoice < 1 || finalChoice > 4);
				
				//if statements for finalChoice
					if (finalChoice == 1)
						score += 100;

					else if (finalChoice == 2)
						score += 250;
			
					else if (finalChoice == 3)
						score += 50;
				
					else if (finalChoice == 4)
						score += 20;

					else
						//display invalid
						cout<<"Invalid. Please enter 1, 2, 3, or 4."<<endl<<endl;

				//display final score
				cout<<"Your final score is "<<score<<"."<<endl<<endl;
				//open file "highscore.txt" for input
				infile.open("highscore.txt", ios::in);

				//read in data
				//read in highName
				getline(infile, highName);
				//read in highscore
				infile>>highscore;

				if (score > highscore)
					{
					//Display congrats
					//Replace old highscore with new highscore
					infile.close();
					
					outfile.open("highscores.txt", ios::out);
					outfile<<firstName<<" "<<score;

					outfile.close();
					}
				}
				else
					//display sorry
					cout<<"Sorry! You didn't beat the high score. Keep trying!"<<endl<<endl;

			}
		else if (locChoice == 2)
			{
			score += 250;

			//display south combatChoice text
			cout<<"Upon your arrival in Medlania, you notice a foul stench violate your sense of smell and begin to evaluate your grim surroundings. Slowly, you begin to examine the homes scattered around the village, your arcane powers ready for combat. After searching for almost an hour, you begin to grow suspicious. Just as you turn to leave the village, you hear a rumble of low growling and grunting. The zombies approach you, dragging their feet and bodies across the dirt. You know what you have to do."<<endl<<endl;

			//display south combatChoice menu
			cout<<"1) Step towards the horde of undead calmly and strike first.\n2) Charge into the group hoping for the best.\n3) Take a defensive approach and wait for them to come before attacking.\n4) RUN FOR IT! You can't do this. Just try not to drown in your own tears."<<endl;


			do
			{
			//prompt for combatChoice
			cout<<"Enter your choice: ";
			cin>>combatChoice;
			
			if (combatChoice < 1 || combatChoice > 4)
				{
				//display invalid
				cout<<"Invalid. Please enter 1, 2, 3, or 4."<<endl<<endl;
				} 
			}
			while (combatChoice < 1 || combatChoice > 4);

			//calculate combatChoice points(RANDOM)
			//seed random number generator
			srand(time(NULL));
			//generate random number 1-100
			coRandom = rand()%100 + 1;

			score += coRandom;
			
			//if statements for combatChoice menu
			if (combatChoice >= 1 && combatChoice <= 4)
				{
				//display finalChoice text
				cout<<"Covered in blood, sweat, and other unidentifiable liquids, you limp back to your own village. An unbearable pain in your thigh seems to be worsening. As you enter the familiar boundaries of your home, you begin searching for your family. You begin to panic, eyes darting around, when nobody is there to greet you. Something is off. Finally, you spot your wife. There's something different about her. 'John...braiiiiiiiins....' she groans. Your eyes well up with tears, it's time to make your final choice."<<endl<<endl;

				//display finalChoice menu
				cout<<"1) Embrace your wife and let her infect you with the plague. Zombie life can't be that bad.\n2) Use all of your remaining strength to kill her. You must protect the greater good.\n3) Surrender yourself to death.\n4) Limp away as fast as you can."<<endl;


				do
				{
				//prompt for finalChoice
				cout<<"Enter your choice: ";
				cin>>finalChoice;
				
				if (finalChoice < 1 || finalChoice > 4)
					{
					//display invalid
					cout<<"Invalid. Please enter 1, 2, 3, or 4."<<endl<<endl;
					}
				}
				while (finalChoice < 1 || finalChoice > 4);

				//if statements for finalChoice
					if (finalChoice == 1)
						score += 100;

					else if (finalChoice == 2)
						score += 250;
			
					else if (finalChoice == 3)
						score += 50;
				
					else if (finalChoice == 4)
						score += 20;

					else
						//display invalid
						cout<<"Invalid. Please enter 1, 2, 3, and 4."<<endl<<endl;

				//display final score
				//open file "highscore.txt" for input
				infile.open("highscore.txt", ios::in);
	
				//read in data
				//read in highName
				getline(infile, highName);
				//read in highscore
				infile>>highscore;

				if (score > highscore)
					{
					//Display congrats
					cout<<"CONGRATULATIONS!! YOU BEAT THE PREVIOUS HIGHSCORE OF "<<highscore<<"!!"<<endl<<endl;

					//Replace old highscore with new highscore
					infile.close();
					
					outfile.open("highscore.txt", ios::out);

					outfile<<firstName<<" "<<score;

					
					outfile.close();					}
					
				else
					//display sorry
					cout<<"Sorry! You didn't beat the highscore. Keep trying!"<<endl<<endl;

			}
		else if (locChoice == 3)
			{
			score += 20;

			//display east combatChoice text
			cout<<"Upon your arrival in Staland, you notice a foul stench violate your sense of smell and begin to evaluate your grim surroundings. Slowly, you begin to examine the homes scattered around the village, your arcane powers ready for combat. After searching for almost an hour, you begin to grow suspicious. Just as you turn to leave the village, you hear a rumble of low growling and grunting. The zombies approach you, dragging their feet and bodies across the dirt. You know what you have to do."<<endl<<endl;

			//display east combatChoice menu
			cout<<"1) Step towards the horde of undead calmly and strike first.\n2) Charge into the group hoping for the best.\n3) Take a defensive approach and wait for them to come before attacking.\n4) RUN FOR IT! You can't do this. Just try not to drown in your own tears."<<endl;

			do
			{
			//prompt for combatChoice
			cout<<"Enter your choice: ";
			cin>>combatChoice;
			
			if (combatChoice < 1 || combatChoice > 4)
				{
				//display invalid
				cout<<"Invalid. Please enter 1, 2, 3, or 4."<<endl<<endl;
				}
			}
			while (combatChoice < 1 || combatChoice > 4);

			//calculate combatChoice points(RANDOM)
			//seed random number generator
			srand(time(NULL));
			//generate random number 1-100
			coRandom = rand()%100 + 1;

			score += coRandom;
			
			//if statements for combatChoice menu
			if (combatChoice >= 1 && combatChoice <= 4)
				{
				//display finalChoice text
				cout<<"Covered in blood, sweat, and other unidentifiable liquids, you limp back to your own village. An unbearable pain in your thigh seems to be worsening. As you enter the familiar boundaries of your home, you begin searching for your family. You begin to panic, eyes darting around, when nobody is there to greet you. Something is off. Finally, you spot your wife. There's something different about her. 'John...braiiiiiiiins....' she groans. Your eyes well up with tears, it's time to make your final choice."<<endl<<endl;

				//display finalChoice menu
				cout<<"1) Embrace your wife and let her infect you with the plague. Zombie life can't be that bad.\n2) Use all of your remaining strength to kill her. You must protect the greater good.\n3) Surrender yourself to death.\n4) Limp away as fast as you can."<<endl;


				do
				{
				//prompt for finalChoice
				cout<<"Enter choice: ";
				cin>>finalChoice;
				
				if (finalChoice < 1 || finalChoice > 4)
					{
					//display invalid
					cout<<"Invalid. Please enter 1, 2, 3, or 4."<<endl<<endl;
					}
				}
				while (finalChoice < 1 || finalChoice > 4);

				//if statements for finalChoice
					if (finalChoice == 1)
						score += 100;

					else if (finalChoice == 2)
						score += 250;
			
					else if (finalChoice == 3)
						score += 50;
				
					else if (finalChoice == 4)
						score += 20;

					else
						//display invalid
						cout<<"Invalid. Please enter 1, 2, 3, or 4."<<endl<<endl;			
			
				//display final score
				cout<<"Your score is "<<score<<"."<<endl<<endl;
				//open file "highscore.txt" for input
				infile.open("highscore.txt", ios::in);
	
				//read in data
				//read in highName
				getline(infile, highName);
				//read in highscore
				infile>>highscore;

				if (score > highscore)
					{
					//Display congrats
					cout<<"CONGRATULATIONS!! YOU BEAT THE PREVIOUS HIGH SCORE OF "<<highscore<<"!!"<<endl<<endl;

					//Replace old highscore with new highscore
					infile.close();

					outfile.open("highscore.txt", ios::out);
			
					outfile<<firstName<<" "<<score;

					
					outfile.close();
					}
				else
					//display sorry
					cout<<"Sorry! You didn't beat the high score. Keep trying!"<<endl<<endl;
			
			
			}
			}	
		else if (locChoice == 4)
			{
			score += 100;

			//display west combatChoice text
			cout<<"Upon your arrival in Cherak, you notice a foul stench violate your sense of smell and begin to evaluate your grim surroundings. Slowly, you begin to examine the homes scattered around the village, your arcane powers ready for combat. After searching for almost an hour, you begin to grow suspicious. Just as you turn to leave the village, you hear a rumble of low growling and grunting. The zombies approach you, dragging their feet and bodies across the dirt. You know what you have to do."<<endl<<endl;

			//display west combatChoice menu
			cout<<"1) Step towards the horde of undead calmly and strike first.\n2) Charge into the group hoping for the best.\n3) Take a defensive approach and wait for them to come before attacking.\n4) RUN FOR IT! You can't do this. Just try not to drown in your own tears."<<endl;


			do
			{
			//prompt for combatChoice
			cout<<"Enter your choice: ";
			cin>>combatChoice;
			
			if (combatChoice < 1 || combatChoice > 4)
				{
				//display invalid
				cout<<"Invalid. Please enter 1, 2, 3, or 4."<<endl<<endl;
				}
			}
			while (combatChoice < 1 || combatChoice > 4);

			//calculate combatChoice points(RANDOM)
			//seed random number generator
			srand(time(NULL));
			//generate random number 1-100
			coRandom = rand()%100 + 1;

			score += coRandom;

			//if statements for combatChoice menu
			//if combatChoice >= 1 and combatChoice <= 4
				//display finalChoice text
				cout<<"Covered in blood, sweat, and other unidentifiable liquids, you limp back to your own village. An unbearable pain in your thigh seems to be worsening. As you enter the familiar boundaries of your home, you begin searching for your family. You begin to panic, eyes darting around, when nobody is there to greet you. Something is off. Finally, you spot your wife. There's something different about her. 'John...braiiiiiiiins....' she groans. Your eyes well up with tears, it's time to make your final choice."<<endl<<endl;

				//display finalChoice menu
				cout<<"1) Embrace your wife and let her infect you with the plague. Zombie life can't be that bad.\n2) Use all of your remaining strength to kill her. You must protect the greater good.\n3) Surrender yourself to death.\n4) Limp away as fast as you can."<<endl;

				
				do
				{
				//prompt for finalChoice
				cout<<"Enter your choice: ";
				cin>>finalChoice;
				
				if (finalChoice < 1 || finalChoice > 4)
					{
					//display invalid
					cout<<"Invalid. Please enter 1, 2, 3, or 4."<<endl<<endl;
					}
				}
				while (finalChoice < 1 || finalChoice > 4);

			
				//if statements for finalChoice
					if (finalChoice == 1)
						score += 100;

					else if (finalChoice == 2)
						score += 250;
			
					else if (finalChoice == 3)
						score += 50;
				
					else if (finalChoice == 4)
						score += 20;

					else
						//display invalid
						cout<<"Invalid. Please enter 1, 2, 3, or 4."<<endl<<endl;

				//display final score
				cout<<"Your score is "<<score<<"."<<endl<<endl;
				//open file "highscore.txt" for input
				infile.open("highscore.txt", ios::in);
	
				//read in data
				//read in highName
				getline(infile, highName);

				//read in highscore
				infile>>highscore;	

				if (score > highscore)
					{
					//Display congrats
					cout<<"CONGRATULATIONS!! YOU HAVE BEATEN THE PREVIOUS HIGHSCORE OF "<<highscore<<"!!"<<endl<<endl;

					//Replace old highscore with new highscore
					infile.close();

					outfile.open("highscore.txt", ios::out);

					outfile<<firstName<<" "<<score;

					outfile.close();
					}	
				else
					//display sorry
					cout<<"Sorry! You didn't beat the highscore. Keep trying!"<<endl<<endl;
			
					

			}
			
			}
			
	else if (introChoice == 3)
		{
		//display priest locChoice text
		cout<<"Quickly running her eyes over your body, the woman scoffed. 'Right. Of course. Well, the plague has spread to several surrounding villages. You can't be in four places at once, but if you really want to help, there are roads leading to each village near the north, south, east, and west exits of our town. Good luck, priest... you're going to need it.'"<<endl<<endl;

		//display priest locChoice menu
		cout<<"1) Go North to Lenville - there are currently 300 zombies and counting.\n2) Go South to Medlania - there are currently 1,000 zombies and counting.\n3) Go East to Staland - there are currently 100 zombies and counting.\n4) Go west to Cherak - there are currently 450 zombies and counting."<<endl;
		
		do
		{
		//prompt for locChoice
		cout<<"Enter your choice: ";		
		cin>>locChoice;
		
		if (locChoice < 1 || locChoice > 4)
			{
			//display invalid
			cout<<"Invalid. Please enter 1, 2, 3, or 4."<<endl<<endl;
			}
		}
		while (locChoice < 1 || locChoice > 4);

		//if statements for locChoice
		if (locChoice == 1)
			{
			score += 50;

			//display north combatChoice text
			cout<<"Upon your arrival in Lenville, you notice a foul stench violate your sense of smell and begin to evaluate your grim surroundings. Slowly, you begin to examine the homes scattered around the village, your holy fire ready for combat. After searching for almost an hour, you begin to grow suspicious. Just as you turn to leave the village, you hear a rumble of low growling and grunting. The zombies approach you, dragging their feet and bodies across the dirt. You know what you have to do."<<endl<<endl;

			//display north combatChoice menu
			cout<<"1) Step towards the horde of undead calmly and strike first.\n2) Charge into the group hoping for the best.\n3) Take a defensive approach and wait for them to come before attacking.\n4) RUN FOR IT! You can't do this. Just try not to drown in your own tears."<<endl;

			do
			{
			//prompt for combatChoice
			cout<<"Enter your choice: ";
			cin>>combatChoice;
			
			if (combatChoice < 1 || combatChoice > 4)
				{
				//display invalid
				cout<<"Invalid. Please enter 1, 2, 3, or 4."<<endl<<endl;
				}
			}
			while (combatChoice < 1 || combatChoice > 4);

			//calculate combatChoice points(RANDOM)
			//seed random number generator
			srand(time(NULL));
			//generate random number 1-100
			coRandom = rand()%100 + 1;
	
			score += coRandom;
			
			//if statements for combatChoice menu
			if (combatChoice >= 1 and combatChoice <= 4)
				{
				//display finalChoice text
				cout<<"Covered in blood, sweat, and other unidentifiable liquids, you limp back to your own village. An unbearable pain in your thigh seems to be worsening. As you enter the familiar boundaries of your home, you begin searching for your family. You begin to panic, eyes darting around, when nobody is there to greet you. Something is off. Finally, you spot your wife. There's something different about her. 'John...braiiiiiiiins....' she groans. Your eyes well up with tears, it's time to make your final choice."<<endl<<endl;

				//display finalChoice menu
				cout<<"1) Embrace your wife and let her infect you with the plague. Zombie life can't be that bad.\n2) Use all of your remaining strength to kill her. You must protect the greater good.\n3) Surrender yourself to death.\n4) Limp away as fast as you can."<<endl;

				do
				{
				//prompt for finalChoice
				cout<<"Enter your choice: ";
				cin>>finalChoice;
				
				if (finalChoice < 1 || finalChoice > 4)
					{
					//display invalid
					cout<<"Invalid. Please enter 1, 2, 3, or 4."<<endl<<endl;
					}
				}
				while (finalChoice < 1 || finalChoice > 4);
		
				
				//if statements for finalChoice
					if (finalChoice == 1)
						score += 100;

					else if (finalChoice == 2)
						score += 250;
			
					else if (finalChoice == 3)
						score += 50;
				
					else if (finalChoice == 4)
						score += 20;

					else
						//display invalid
						cout<<"Invalid. Please enter 1, 2, 3, or 4."<<endl<<endl;


				//display final score
				cout<<"Your score is "<<score<<"."<<endl<<endl;

				//open file "highscore.txt" for input
				infile.open("highscore.txt", ios::in);
	
				//read in data
				//read in highName
				getline(infile, highName);

				//read in highscore
				infile>>highscore;
	
				if (score > highscore)
					{
					//Display congrats
					cout<<"CONGRATULATIONS!! YOU HAVE BEATEN THE PREVIOUS HIGHSCORE OF "<<highscore<<"!!"<<endl<<endl;
					//Replace old highscore with new highscore
					infile.close();
		
					outfile.open("highscore.txt", ios::out);
				
					outfile<<firstName<<" "<<score;

					outfile.close();
					}	
				else
					//display sorry
					cout<<"Sorry! You didn't beat the highscore. Keep trying!"<<endl<<endl;
			
			
			}
			}
		else if (locChoice == 2)
			{
			score += 250;

			//display south combatChoice text
			cout<<"Upon your arrival in Medlania, you notice a foul stench violate your sense of smell and begin to evaluate your grim surroundings. Slowly, you begin to examine the homes scattered around the village, your holy fire ready for combat. After searching for almost an hour, you begin to grow suspicious. Just as you turn to leave the village, you hear a rumble of low growling and grunting. The zombies approach you, dragging their feet and bodies across the dirt. You know what you have to do."<<endl<<endl;

			//display south combatChoice menu
			cout<<"1) Step towards the horde of undead calmly and strike first.\n2) Charge into the group hoping for the best.\n3) Take a defensive approach and wait for them to come before attacking.\n4) RUN FOR IT! You can't do this. Just try not to drown in your own tears."<<endl;

			do
			{
			//prompt for combatChoice
			cout<<"Enter your choice: ";
			cin>>combatChoice;
			
			if (combatChoice < 1 || combatChoice > 4)
				{
				//display invalid
				cout<<"Invalid. Please enter 1, 2, 3, or 4."<<endl<<endl;
				}
			}
			while (combatChoice < 1 || combatChoice > 4);

			//calculate combatChoice points(RANDOM)
			//seed random number generator
			srand(time(NULL));

			//generate random number 1-100
			coRandom = rand()%100 + 1;
		
			score += coRandom;
			
			//if statements for combatChoice menu
			if (combatChoice >= 1 && combatChoice <= 4)
				{
				//display finalChoice text
				cout<<"Covered in blood, sweat, and other unidentifiable liquids, you limp back to your own village. An unbearable pain in your thigh seems to be worsening. As you enter the familiar boundaries of your home, you begin searching for your family. You begin to panic, eyes darting around, when nobody is there to greet you. Something is off. Finally, you spot your wife. There's something different about her. 'John...braiiiiiiiins....' she groans. Your eyes well up with tears, it's time to make your final choice."<<endl<<endl;

				//display finalChoice menu
				cout<<"1) Embrace your wife and let her infect you with the plague. Zombie life can't be that bad.\n2) Use all of your remaining strength to kill her. You must protect the greater good.\n3) Surrender yourself to death.\n4) Limp away as fast as you can."<<endl;


				do
				{
				//prompt for finalChoice
				cout<<"Enter your choice: ";
				cin>>finalChoice;
				
				if (finalChoice < 1 || finalChoice > 4)
					{
					//display invalid
					cout<<"Invalid. Please enter 1, 2, 3, or 4."<<endl<<endl;
					}
				}
				while (finalChoice < 1 || finalChoice > 4);
				
				//if statements for finalChoice
					if (finalChoice == 1)
						score += 100;

					else if (finalChoice == 2)
						score += 250;
			
					else if (finalChoice == 3)
						score += 50;
				
					else if (finalChoice == 4)
						score += 20;

					else
						//display invalid
						cout<<"Invalid. Please enter 1, 2, 3, or 4."<<endl<<endl;

				//display final score
				cout<<"Your score is "<<score<<"."<<endl<<endl;

				//open file "highscore.txt" for input
				infile.open("highscore.txt", ios::in);	

				//read in data
				//read in highName
				getline(infile, highName);

				//read in highscore
				infile>>highscore;

				if (score > highscore)
					{
					//Display congrats
					cout<<"CONGRATULATIONS!! YOU HAVE BEATEN THE PREVIOUS HIGHSCORE OF "<<highscore<<"!!"<<endl<<endl;

					//Replace old highscore with new highscore
					infile.close();

					outfile.open("highscore.txt", ios::out);

					outfile<<firstName<<" "<<score;	

					outfile.close();
					}
				else
					//display sorry
					cout<<"Sorry! You didn't beat the highscore. Keep trying!"<<endl<<endl;

			}
			}
			
		else if (locChoice == 3)
			{
			score += 20;

			//display east combatChoice text
			cout<<"Upon your arrival in Staland, you notice a foul stench violate your sense of smell and begin to evaluate your grim surroundings. Slowly, you begin to examine the homes scattered around the village, your holy fire ready for combat. After searching for almost an hour, you begin to grow suspicious. Just as you turn to leave the village, you hear a rumble of low growling and grunting. The zombies approach you, dragging their feet and bodies across the dirt. You know what you have to do."<<endl<<endl;

			//display east combatChoice menu
			cout<<"1) Step towards the horde of undead calmly and strike first.\n2) Charge into the group hoping for the best.\n3) Take a defensive approach and wait for them to come before attacking.\n4) RUN FOR IT! You can't do this. Just try not to drown in your own tears."<<endl;


			do
			{
			//prompt for combatChoice
			cout<<"Enter your choice: ";
			cin>>combatChoice;
			
			if (combatChoice < 1 || combatChoice > 4)
				{
				//display invalid
				cout<<"Invalid. Please enter 1, 2, 3, or 4."<<endl<<endl;
				}
			}
			while (combatChoice < 1 || combatChoice > 4);
			
				
			//calculate combatChoice points(RANDOM)
			//seed random number generator
			srand(time(NULL));

			//generate random number 1-100
			coRandom = rand()%100 + 1;

			score += coRandom;
			
			//if statements for combatChoice menu
			if (combatChoice >= 1 and combatChoice <= 4)
				{
				//display finalChoice text
				cout<<"Covered in blood, sweat, and other unidentifiable liquids, you limp back to your own village. An unbearable pain in your thigh seems to be worsening. As you enter the familiar boundaries of your home, you begin searching for your family. You begin to panic, eyes darting around, when nobody is there to greet you. Something is off. Finally, you spot your wife. There's something different about her. 'John...braiiiiiiiins....' she groans. Your eyes well up with tears, it's time to make your final choice."<<endl<<endl;

				//display finalChoice menu
				cout<<"1) Embrace your wife and let her infect you with the plague. Zombie life can't be that bad.\n2) Use all of your remaining strength to kill her. You must protect the greater good.\n3) Surrender yourself to death.\n4) Limp away as fast as you can."<<endl;


				do
				{
				//prompt for finalChoice
				cout<<"Enter your choice: ";
				cin>>finalChoice;
				
				if (finalChoice < 1 || finalChoice > 4)
					{
					//display invalid
					cout<<"Invalid. Please enter 1, 2, 3, or 4."<<endl<<endl;
					}
				}
				while (finalChoice < 1 || finalChoice > 4);
				
				//if statements for finalChoice
					if (finalChoice == 1)
						score += 100;

					else if (finalChoice == 2)
						score += 250;
			
					else if (finalChoice == 3)
						score += 50;
				
					else if (finalChoice == 4)
						score += 20;

					else
						//display invalid
						cout<<"Invalid. Please enter 1, 2, 3, or 4."<<endl<<endl;

				//display final score
				cout<<"Your score is "<<score<<"."<<endl<<endl;

				//open file "highscore.txt" for input
				infile.open("highscore.txt", ios::in);
	
				//read in data
				//read in highName
				getline(infile, highName);

				//read in highscore
				infile>>highscore;

				if (score > highscore)
					{
					//Display congrats
					cout<<"CONGRATULATIONS!! YOU HAVE BEATEN THE PREVIOUS HIGH SCORE OF "<<highscore<<"!!"<<endl<<endl;

					//Replace old highscore with new highscore
					infile.close();
				
					outfile.open("highscore.txt", ios::out);

					outfile<<firstName<<" "<<score;	

					outfile.close();
					}
				else
					//display sorry
					cout<<"Sorry! You did not beat the highscore. Keep trying!"<<endl<<endl;


				
			}
			}			
		else if (locChoice == 4)
			{
			score += 100;

			//display west combatChoice text
			cout<<"Upon your arrival in Cherak, you notice a foul stench violate your sense of smell and begin to evaluate your grim surroundings. Slowly, you begin to examine the homes scattered around the village, your holy fire ready for combat. After searching for almost an hour, you begin to grow suspicious. Just as you turn to leave the village, you hear a rumble of low growling and grunting. The zombies approach you, dragging their feet and bodies across the dirt. You know what you have to do."<<endl<<endl;

			//display west combatChoice menu
			cout<<"1) Step towards the horde of undead calmly and strike first.\n2) Charge into the group hoping for the best.\n3) Take a defensive approach and wait for them to come before attacking.\n4) RUN FOR IT! You can't do this. Just try not to drown in your own tears."<<endl;


			do
			{
			//prompt for combatChoice
			cout<<"Enter your choice: ";
			cin>>combatChoice;
			
			if (combatChoice < 1 || combatChoice > 4)
				{
				//display invalid
				cout<<"Invalid. Please enter 1, 2, 3, or 4."<<endl<<endl;
				}
			}
			while (combatChoice < 1 || combatChoice > 4);

			//calculate combatChoice points(RANDOM)
			//seed random number generator
			srand(time(NULL));

			//generate random number 1-100
			coRandom = rand()%100 + 1;

			score += coRandom;
			
			//if statements for combatChoice menu
			if (combatChoice >= 1 and combatChoice <= 4)
				{
				//display finalChoice text
				cout<<"Covered in blood, sweat, and other unidentifiable liquids, you limp back to your own village. An unbearable pain in your thigh seems to be worsening. As you enter the familiar boundaries of your home, you begin searching for your family. You begin to panic, eyes darting around, when nobody is there to greet you. Something is off. Finally, you spot your wife. There's something different about her. 'John...braiiiiiiiins....' she groans. Your eyes well up with tears, it's time to make your final choice."<<endl<<endl;

				//display finalChoice menu
				cout<<"1) Embrace your wife and let her infect you with the plague. Zombie life can't be that bad.\n2) Use all of your remaining strength to kill her. You must protect the greater good.\n3) Surrender yourself to death.\n4) Limp away as fast as you can."<<endl;

				do
				{
				//prompt for finalChoice
				cout<<"Enter your choice: ";
				cin>>finalChoice;
				
				if (finalChoice < 1 || finalChoice > 4)
					{
					//display invalid
					cout<<"Invalid. Please enter 1, 2, 3, or 4."<<endl<<endl;
					}
				}
				while (finalChoice < 1 || finalChoice > 4);
				
				//if statements for finalChoice
					if (finalChoice == 1)
						score += 100;

					else if (finalChoice == 2)
						score += 250;
			
					else if (finalChoice == 3)
						score += 50;
				
					else if (finalChoice == 4)
						score += 20;

					else
						//display invalid
						cout<<"Invalid. Please enter 1, 2, 3, or 4."<<endl<<endl;

				//display final score
				cout<<"Your score is "<<score<<"."<<endl<<endl;				

				//open file "highscore.txt" for input
				infile.open("highscore.txt", ios::in);
	
				//read in data
				//read in highName
				getline(infile, highName);

				//read in highscore
				infile>>highscore;

				if (score > highscore)
					{
					//Display congrats
					cout<<"CONGRATULATIONS!! YOU HAVE BEATEN THE PREVIOUS HIGHSCORE OF "<<highscore<<"!!"<<endl<<endl;

					//Replace old highscore with new highscore
					infile.close();

					outfile.open("highscore.txt", ios::out);
		
					outfile<<firstName<<" "<<score;

					outfile.close();	
					}
				else
					//display sorry
					cout<<"Sorry! You didn't beat the high score. Keep trying!"<<endl<<endl;

			
			}
			}		
	else if (introChoice == 4)
		{
		//display assassin locChoice text
		cout<<"Quickly running her eyes over your body, the woman scoffed. 'Right. Of course.	Well, the plague has spread to several surrounding villages. You can't be in four places at once, but if you really want to help, there are roads leading to each village near the north, south, east, and west exits of our town. Good luck, assassin... you're going to need it.'"<<endl<<endl;
	
		//display assassin locChoice menu
		cout<<"1) Go North to Lenville - there are currently 300 zombies and counting.\n2) Go South to Medlania - there are currently 1,000 zombies and counting.\n3) Go East to Staland - there are currently 100 zombies and counting.\n4) Go west to Cherak - there are currently 450 zombies and counting."<<endl<<endl;
		

		do
		{
		//prompt for locChoice
		cout<<"Enter your choice: ";
		cin>>locChoice;
		
		if (locChoice < 1 || locChoice > 4)
			{
			//display invalid
			cout<<"Invalid. Please enter 1, 2, 3, or 4."<<endl<<endl;
			}
		}
		while (locChoice < 1 || locChoice > 4);		

		//if statements for combatChoice menu
			if (combatChoice >= 1 and combatChoice <= 4)
				{
				//display finalChoice text
				cout<<"Covered in blood, sweat, and other unidentifiable liquids, you limp back to your own village. An unbearable pain in your thigh seems to be worsening. As you enter the familiar boundaries of your home, you begin searching for your family. You begin to	panic, eyes darting around, when nobody is there to greet you. Something is off. Finally, you spot your wife. There's something different about her. 'John...braiiiiiiiins....' she groans. Your eyes well up with tears, it's time to make your final choice."<<endl<<endl;

				//display finalChoice menu
				cout<<"1) Embrace your wife and let her infect you with the plague. Zombie life can't be that bad.\n2) Use all of your remaining strength to kill her. You must protect the greater good.\n3) Surrender yourself to death.\n4) Limp away as fast as you can."<<endl;

				do
				{
				//prompt for finalChoice
				cout<<"Enter your choice: ";
				cin>>finalChoice;
				
				if (finalChoice < 1 || finalChoice > 4)
					{
					//display invalid
					cout<<"Invalid. Please enter 1, 2, 3, or 4."<<endl<<endl;
					}
				}
				while (finalChoice < 1 || finalChoice > 4);
				
				//if statements for finalChoice
					if (finalChoice == 1)
						score += 100;

					else if (finalChoice == 2)
						score += 250;
			
					else if (finalChoice == 3)
						score += 50;
				
					else if (finalChoice == 4)
						score += 20;

					else
						//display invalid
						cout<<"Invalid. Please enter 1, 2, 3, or 4."<<endl<<endl;

				//display final score
				cout<<"Your score is "<<score<<"."<<endl<<endl;

				//open file "highscore.txt" for input
				infile.open("highscore.txt", ios::in);

				//read in data
				//read in highName
				getline(infile, highName);
	
				//read in highscore
				infile>>highscore;

				if (score > highscore)
					{
					//Display congrats
					cout<<"CONGRATULATIONS!! YOU HAVE BEATEN THE PREVIOUS HIGHSCORE OF "<<highscore<<"!!"<<endl<<endl;

					//Replace old highscore with new highscore
					infile.close();
					
					outfile.open("highscore.txt", ios::out);
		
					outfile<<firstName<<" "<<score;
					}
				else
					//display sorry
					cout<<"Sorry! You didn't beat the highscore. Keep trying!"<<endl<<endl;

			

			}
			}
	//if statements for locChoice
		if (locChoice == 1)
			{
			score += 50;

			//display north combatChoice text
			cout<<"Upon your arrival in Lenville, you notice a foul stench violate your sense of smell and begin to evaluate your grim surroundings. Slowly, you begin to examine the homes scattered around the village, your traps and poisons ready for combat. After searching for almost an hour, you begin to grow suspicious. Just as you turn to leave the village, you hear a rumble of low growling and grunting. The zombies approach you, dragging their feet and bodies across the dirt. You know what you have to do."<<endl<<endl;

			//display north combatChoice menu
			cout<<"1) Step towards the horde of undead calmly and strike first.\n2) Charge into the group hoping for the best.\n3) Take a defensive approach and wait for them to come before attacking.\n4) RUN FOR IT! You can't do this. Just try not to drown in your own tears."<<endl;

			do
			{
			//prompt for combatChoice
			cout<<"Enter your choice: ";
			cin>>combatChoice;
			
			if (combatChoice < 1 || combatChoice > 4)
				{
				//display invalid
				cout<<"Invalid. Please enter 1, 2, 3, or 4."<<endl<<endl;
				}
			}
			while (combatChoice < 1 || combatChoice > 4);

			//calculate combatChoice points(RANDOM)
			//seed random number generator
			srand(time(NULL));

			//generate random number 1-100
			coRandom = rand()%100 + 1;

			score += coRandom;
			
			//if statements for combatChoice menu
			if (combatChoice >= 1 && combatChoice <= 4)
				{
				//display finalChoice text
				cout<<"Covered in blood, sweat, and other unidentifiable liquids, you limp back to your own village. An unbearable pain in your thigh seems to be worsening. As you enter the familiar boundaries of your home, you begin searching for your family. You begin to panic, eyes darting around, when nobody is there to greet you. Something is off. Finally, you spot your wife. There's something different about her. 'John...braiiiiiiiins....' she groans. Your eyes well up with tears, it's time to make your final choice."<<endl<<endl;

				//display finalChoice menu
				cout<<"1) Embrace your wife and let her infect you with the plague. Zombie life can't be that bad.\n2) Use all of your remaining strength to kill her. You must protect the greater good.\n3) Surrender yourself to death.\n4) Limp away as fast as you can."<<endl;

				do
				{
				//prompt for finalChoice
				cout<<"Enter your choice: ";
				cin>>finalChoice;
				
				if (finalChoice < 1 || finalChoice > 4)
					{
					//display invalid
					cout<<"Invalid. Please enter 1, 2, 3, or 4."<<endl<<endl;
					}
				}
				while (finalChoice < 1 || finalChoice > 4);
				
				//if statements for finalChoice
					if (finalChoice == 1)
						score += 100;

					else if (finalChoice == 2)
						score += 250;
			
					else if (finalChoice == 3)
						score += 50;
				
					else if (finalChoice == 4)
						score += 20;

					else
						//display invalid
						cout<<"Invalid. Please enter 1, 2, 3, or 4."<<endl<<endl;

				//display final score
				cout<<"Your score is "<<score<<"."<<endl<<endl;

				//open file "highscore.txt" for input
				infile.open("highscore.txt", ios::in);	

				//read in data
				//read in highName
				getline(infile, highName);

				//read in highscore
				infile>>highscore;

				if (score > highscore)
					{
					//Display congrats
					cout<<"CONGRATULATIONS!! YOU HAVE BEATEN THE HIGHSCORE OF "<<highscore<<"!!"<<endl<<endl;

					//Replace old highscore with new highscore
					infile.close();

					outfile.open("highscore.txt", ios::out);

					outfile<<firstName<<" "<<score;

					outfile.close();
					}
				else
					//display sorry
					cout<<"Sorry. You didn't beat the high score. Keep trying!"<<endl<<endl;

		
			}
			}
		else if (locChoice == 2)
			{
			score += 250;

			//display south combatChoice text
			cout<<"Upon your arrival in Medlania, you notice a foul stench violate your sense of smell and begin to evaluate your grim surroundings. Slowly, you begin to examine the homes scattered around the village, your traps and poisons ready for combat. After searching for almost an hour, you begin to grow suspicious. Just as you turn to leave the village, you hear a rumble of low growling and grunting. The zombies approach you, dragging their feet and bodies across the dirt. You know what you have to do."<<endl<<endl;

			//display south combatChoice menu
			cout<<"1) Step towards the horde of undead calmly and strike first.\n2) Charge into the group hoping for the best.\n3) Take a defensive approach and wait for them to come before attacking.\n4) RUN FOR IT! You can't do this. Just try not to drown in your own tears."<<endl;

			do
			{
			//prompt for combatChoice
			cout<<"Enter your choice: ";
			cin>>combatChoice;
			
			if (combatChoice < 1 || combatChoice > 4)
				{
				//display invalid
				cout<<"Invalid. Please enter 1, 2, 3, or 4."<<endl<<endl;
				}
			}
			while (combatChoice < 1 || combatChoice > 4);

			//calculate combatChoice points(RANDOM)
			//seed random number generator
			srand(time(NULL));

			//generate random number 1-100
			coRandom = rand()%100 + 1;

			score += coRandom;
			
			//if statements for combatChoice menu
			if (combatChoice >= 1 and combatChoice <= 4)
				{
				//display finalChoice text
				cout<<"Covered in blood, sweat, and other unidentifiable liquids, you limp back to your own village. An unbearable pain in your thigh seems to be worsening. As you enter the familiar boundaries of your home, you begin searching for your family. You begin to panic, eyes darting around, when nobody is there to greet you. Something is off. Finally, you spot your wife. There's something different about her. 'John...braiiiiiiiins....' she groans. Your eyes well up with tears, it's time to make your final choice."<<endl<<endl;

				//display finalChoice menu
				cout<<"1) Embrace your wife and let her infect you with the plague. Zombie life can't be that bad.\n2) Use all of your remaining strength to kill her. You must protect the greater good.\n3) Surrender yourself to death.\n4) Limp away as fast as you can."<<endl;


				do
				{
				//prompt for finalChoice
				cout<<"Enter your choice: ";
				cin>>finalChoice;
				
				if (finalChoice < 1 || finalChoice > 4)
					{
					//display invalid
					cout<<"Invalid. Please enter 1, 2, 3, or 4."<<endl<<endl;
					}
				}
				while (finalChoice < 1 || finalChoice > 4);
				
				//if statements for finalChoice
					if (finalChoice == 1)
						score += 100;

					else if (finalChoice == 2)
						score += 250;
			
					else if (finalChoice == 3)
						score += 50;
				
					else if (finalChoice == 4)
						score += 20;

					else
						//display invalid
						cout<<"Invalid. Please enter 1, 2, 3, or 4."<<endl<<endl;

				//display final score
				cout<<"Your score is "<<score<<"."<<endl<<endl;

				//open file "highscore.txt" for input
				infile.open("highscore.txt", ios::in);
	
				//read in data
				//read in highName
				getline(infile, highName);				

				//read in highscore
				infile>>highscore;

				if (score > highscore)
					{
					//Display congrats
					cout<<"CONGRATULATIONS!! YOU HAVE BEATEN THE PREVIOUS HIGHSCORE OF "<<highscore<<"!!"<<endl<<endl;

					//Replace old highscore with new highscore
					infile.close();
					
					outfile.open("highscore.txt", ios::out);

					outfile<<firstName<<" "<<score;
					}

					
				else
					//display sorry
					cout<<"Sorry! You did not beat the highscore. Keep trying!"<<endl<<endl;
			
			
			}
			}
		else if (locChoice == 3)
			{
			score += 20;

			//display east combatChoice text
			cout<<"Upon your arrival in Staland, you notice a foul stench violate your sense of smell and begin to evaluate your grim surroundings. Slowly, you begin to examine the homes scattered around the village, your traps and poisons ready for combat. After searching for almost an hour, you begin to grow suspicious. Just as you turn to leave the village, you hear a rumble of low growling and grunting. The zombies approach you, dragging their feet and bodies across the dirt. You know	what you have to do."<<endl<<endl;

			//display east combatChoice menu
			cout<<"1) Step towards the horde of undead calmly and strike first.\n2) Charge into the group hoping for the best.\n3) Take a defensive approach and wait for them to come before attacking.\n4) RUN FOR IT! You can't do this. Just try not to drown in your own tears."<<endl;


			do
			{
			//prompt for combatChoice
			cout<<"Enter your choice: ";
			cin>>combatChoice;
			
			if (combatChoice < 1 || combatChoice > 4)
				{
				//display invalid
				cout<<"Invalid. Please enter 1, 2, 3, or 4."<<endl<<endl;
				}
			}
			while (combatChoice < 1 || combatChoice > 4);

			//calculate combatChoice points(RANDOM)
			//seed random number generator
			srand(time(NULL));			

			//generate random number 1-100
			coRandom = rand()%100 + 1;

			score += coRandom;

			//if statements for combatChoice menu
			if (combatChoice >= 1 && combatChoice <= 4)
				{
				//display finalChoice text
				cout<<"Covered in blood, sweat, and other unidentifiable liquids, you limp back to your own village. An unbearable pain in your thigh seems to be worsening. As you enter the familiar boundaries of your home, you begin searching for your family. You begin to panic, eyes darting around, when nobody is there to greet you. Something is off. Finally, you spot your wife. There's something different about her. 'John...braiiiiiiiins....' she groans. Your eyes well up with tears, it's time to make your final choice."<<endl<<endl;

				//display finalChoice menu
				cout<<"1) Embrace your wife and let her infect you with the plague. Zombie life can't be that bad.\n2) Use all of your remaining strength to kill her. You must protect the greater good.\n3) Surrender yourself to death.\n4) Limp away as fast as you can."<<endl;

				do
				{
				//prompt for finalChoice
				cout<<"Enter your choice: ";
				cin>>finalChoice;
				
				if (finalChoice < 1 || finalChoice > 4)
					{
					//display invalid
					cout<<"Invalid. Please enter 1, 2, 3, or 4."<<endl<<endl;
					}
				}
				while (finalChoice < 1 || finalChoice > 4);
				
				//if statements for finalChoice
					if (finalChoice == 1)
						score += 100;

					else if (finalChoice == 2)
						score += 250;
			
					else if (finalChoice == 3)
						score += 50;
				
					else if (finalChoice == 4)
						score += 20;

					else
						//display invalid
						cout<<"Invalid. Please enter 1, 2, 3, or 4."<<endl<<endl;

				//display final score
				cout<<"Your score is "<<score<<"."<<endl<<endl;

				//open file "highscore.txt" for input
				infile.open("highscore.txt", ios::in);

				//read in data
				//read in highName
				getline(infile, highName);

				//read in highscore
				infile>>highscore;

				if (score > highscore)
					{
					//Display congrats
					cout<<"CONGRATULATIONS!! YOU HAVE BEATEN THE PREVIOUS HIGHSCORE OF "<<highscore<<"!!"<<endl<<endl;

					//Replace old highscore with new highscore
					infile.close();
			
					outfile.open("highscore.txt", ios::out);

					outfile<<firstName<<" "<<score;
	
					}
				else
					//display sorry
					cout<<"Sorry! You didn't beat the highsocre. Keep trying!"<<endl<<endl;

			

			}
			}
		else if (locChoice == 4)
			{
			score += 100;

			//display west combatChoice text
			cout<<"Upon your arrival in Cherak, you notice a foul stench violate your sense of smell and begin to evaluate your grim surroundings. Slowly, you begin to examine the homes scattered around the village, your traps and poisons ready for combat. After searching for almost an hour, you begin to grow suspicious. Just as you turn to leave the village, you hear a rumble of low growling and grunting. The zombies approach you, dragging their feet and bodies across the dirt. You know what you have to do."<<endl<<endl;

			//display west combatChoice menu
			cout<<"1) Step towards the horde of undead calmly and strike first.\n2) Charge into the group hoping for the best.\n3) Take a defensive approach and wait for them to come before attacking.\n4) RUN FOR IT! You can't do this. Just try not to drown in your own tears."<<endl;


			do
			{
			//prompt for combatChoice
			cout<<"Enter your choice: ";
			cin>>combatChoice;
			
			if (combatChoice < 1 || combatChoice > 4)
				{
				//display invalid
				cout<<"Invalid. Please enter 1, 2, 3, or 4."<<endl<<endl;
				}
			}
			while (combatChoice < 1 || combatChoice > 4);

			//calculate combatChoice points(RANDOM)
			//seed random number generator
			srand(time(NULL));

			//generate random number 1-100
			coRandom = rand()%100 + 1;

			score += coRandom;

			//if statements for combatChoice menu
			if (combatChoice >= 1 && combatChoice <= 4)
				{
				//display finalChoice text
				cout<<"Covered in blood, sweat, and other unidentifiable liquids, you limp back to your own village. An unbearable pain in your thigh seems to be worsening. As you enter the familiar boundaries of your home, you begin searching for your family. You begin to panic, eyes darting around, when nobody is there to greet you. Something is off. Finally, you spot your wife. There's something different about her. 'John...braiiiiiiiins....' she groans. Your eyes well up with tears, it's time to make your final choice."<<endl<<endl;

				//display finalChoice menu
				cout<<"1) Embrace your wife and let her infect you with the plague. Zombie life can't be that bad.\n2) Use all of your remaining strength to kill her. You must protect the greater good.\n3) Surrender yourself to death.\n4) Limp away as fast as you can."<<endl;
		
				do
				{
				//prompt for finalChoice
				cout<<"Enter your choice: ";
				cin>>finalChoice;
				
				if (finalChoice < 1 || finalChoice > 4)
					{
					//display invalid
					cout<<"Invalid. Please enter 1, 2, 3, or 4."<<endl<<endl;
					}
				}
				while (finalChoice < 1 || finalChoice > 4);
				
				//if statements for finalChoice
					if (finalChoice == 1)
						score += 100;

					else if (finalChoice == 2)
						score += 250;
			
					else if (finalChoice == 3)
						score += 50;
				
					else if (finalChoice == 4)
						score += 20;

					else
						//display invalid
						cout<<"Invalid. Please enter 1, 2, 3, or 4."<<endl<<endl;

				//display final score
				cout<<"Your score is "<<score<<"."<<endl<<endl;

				//open file "highscore.txt" for input
				infile.open("highscore.txt", ios::in);
	
				//read in data
				//read in highName
				getline(infile, highName);

				//read in highscore
				infile>>highscore;

				if (score > highscore)
					{
					//Display congrats
					cout<<"CONGRATULATIONS!! YOU HAVE BEAT THE PREVIOUS HIGHSCORE OF "<<highscore<<"!!"<<endl<<endl;

					//Replace old highscore with new highscore
					infile.close();

					outfile.open("highscore.txt", ios::out);

					outfile<<firstName<<" "<<score;

					}
				else
					//display sorry
					cout<<"Sorry! You didn't beat the highscore. Keep trying!"<<endl<<endl;

			
		}
		}
	else if (mainChoice == 3)
		//display goodbye, end game
		cout<<"Thanks for playing! Goodbye."<<endl;


	}
	}


	
	}
	while (mainChoice != 3);


 return 0;
}



Is This A Good Question/Topic? 0
  • +

Replies To: Program not working as intended, no syntax error from compiler

#2 jimblumberg   User is offline

  • member icon

Reputation: 5733
  • View blog
  • Posts: 17,568
  • Joined: 25-December 09

Re: Program not working as intended, no syntax error from compiler

Posted 13 March 2012 - 08:10 PM

You may want to insure your compiler is generating warnings and the highest possible level is applied. When I compile your code I get the following warning:

Quote

||=== c++homework, Debug ===|
main.cpp||In function ‘int main()’:|
main.cpp|372|warning: suggest braces around empty body in an ‘if’ statement|
||=== Build finished: 0 errors, 1 warnings ===|


This may be the cause of part of your problems.

Jim
Was This Post Helpful? 0
  • +
  • -

#3 kioam   User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 3
  • Joined: 13-March 12

Re: Program not working as intended, no syntax error from compiler

Posted 13 March 2012 - 09:22 PM

Thanks for the quick reply.

I cannot change any settings in the compiler because I have very restricted access to settings for my school software. I added braces where they were missing and my problems still persist. I am thinking maybe it is somehow getting confused with so many menus inside of each other but I cannot think of a different way to word it. (We have just started to cover functions, which seem really useful but I don't know enough about them and we aren't allowed to use what we have not learned yet in our work).

I noticed a problem that I think I missed/did not mention in the first post, when I choose the "play" option and then choose the first menu option (the one that is working), I get the next menu as I should but if I select two or four I just get the main menu displayed again. I thought it worked all the way through no matter what I chose but I must have overlooked it. I look at those two else if's specifically but didn't notice anything unusual there :stupid:

Originally I had all my input validation done through the if structures like in the main menu (if choice == 1, if choice == 2, if choice == 3, else invalid) but I was getting horrible masses of errors during compiling that said that those final "else" statements at the end of my menus needed to have if statements before them. I changed the input validation to small do while loops after every prompt but maybe that's the problem?

Sorry for rambling, might be talking about nothing here.. :dontgetit:
Was This Post Helpful? 1
  • +
  • -

#4 sungchoiok   User is offline

  • D.I.C Head
  • member icon

Reputation: 44
  • View blog
  • Posts: 140
  • Joined: 18-July 10

Re: Program not working as intended, no syntax error from compiler

Posted 13 March 2012 - 09:22 PM

if (finalChoice < 1 || finalChoice > 4);


It's that semicolon after the "if" statement. (line 372)



With that being said, I'm sure you recognize the problem yourself, but the fact that you used ONE FUNCTION to code 2000 lines of code is in itself begging for trouble. (and is quite impressive actually :D)

I hope you get to learn functions soon. Before you do, this project is... almost impossible to debug. I'll plug the code into my compiler and see what it says.

This post has been edited by sungchoiok: 13 March 2012 - 09:27 PM

Was This Post Helpful? 3
  • +
  • -

#5 sungchoiok   User is offline

  • D.I.C Head
  • member icon

Reputation: 44
  • View blog
  • Posts: 140
  • Joined: 18-July 10

Re: Program not working as intended, no syntax error from compiler

Posted 13 March 2012 - 09:37 PM

ok, something's definitely not lining up here.

look: (starting at line 35)
do {
        //display main menu
        cout<<"1) See Rules\n2) Play Game\n3) Quit\n";

        //prompt for mainChoice
        cout<<"Enter your choice: ";
        cin>>mainChoice;


        //if statements for main menu choice
        if (mainChoice == 1)
        {
            //display rules and story
        }
        else if (mainChoice == 2)
        {
...
...



notice how if (mainChoice == 1) and else if (mainChoice == 2) begins right after "do" bracket?


Now, look where else if (mainChoice == 3) begin.

[starting at line 1962]
...
...
                    }
                }
                else if (mainChoice == 3)
                    //display goodbye, end game
                    cout<<"Thanks for playing! Goodbye."<<endl;
            }
        }
    }
    while (mainChoice != 3);


It's two levels in, and is actually lining up with if (locChoice == # ) and NOT with the previous two mainChoices.

Something's very wrong, and you're going to end up scrolling through 2000 lines of code with a ruler in your hand, seeing if the "if" and loop statement brackets match up 900 lines down the page. Sorry for being so pessimistic :(

This post has been edited by sungchoiok: 13 March 2012 - 09:40 PM

Was This Post Helpful? 2
  • +
  • -

#6 kioam   User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 3
  • Joined: 13-March 12

Re: Program not working as intended, no syntax error from compiler

Posted 14 March 2012 - 05:57 AM

So after scrolling through 2000 lines of code as suggested and redoing my brackets, I compile with no error but once I go to choose something from the main menu my program goes into an infinite loop and says something about my choice being invalid even though I entered correctly.. is this still brackets causing the issue? Feeling ridiculous here :splat:

/* project1.cpp
March 13, 2012
This is a text-based RPG named John's Zombies
*/

#include <iostream>
#include <fstream>
#include <ctime>
#include <string>

using namespace std;

int main()
{
	//declare and initialize variables
	int mainChoice = 0, introChoice = 0, locChoice = 0, combatChoice = 0,finalChoice = 0; 		int score = 0, cRandom = 0, coRandom = 0, highscore = 0;
	string firstName, highName;

	//declare file pointer for input
	ifstream infile;

	//declare file pointer for output
	ofstream outfile;

	//Intro
	cout<<"WELCOME TO JOHN'S ZOMBIES!"<<endl<<endl;
	
	//prompt for firstName
	cout<<"Enter your first name: ";
	cin>>firstName;
	cout<<endl;

	//begin do while loop for main menu
	do
	{
	//display main menu
	cout<<"1) See Rules\n2) Play Game\n3) Quit\n";

	//prompt for mainChoice
	cout<<"Enter your choice: ";
	cin>>mainChoice;
	

	//if statements for main menu choice
	if (mainChoice == 1)
	{
	//display rules and story
	cout<<"The plague is upon us. Slowly but surely, all of the people of the great Mother Land are becoming infected and turned into undead. Ruthless, disgusting, and viscious creatures - these 'zombies' roam through villages and infect men, women, and children one by one. Their army is only getting stronger. Your story begins here, hero... you WILL be a legend. Alive or not, well, that depends entirely on your choices. Remember: you cannot control it all; sometimes fate must choose for you.\n\nRead through the story of the game and make important 	decisions when prompted. Your score will be based on your decisions, but some of your score will be out of your hands! Tread lightly.."<<endl<<endl;

	}
	else if (mainChoice == 2)
	{
	//begin game

	//initialize counter
	score = 0;

	//display intro text
	cout<<"You hear a young woman screaming, 'The zombie plague is coming! THE ZOMBIE PLAGUE IS COMING!!!' Having heard the news earlier, you decide to step up and take on the undead yourself. You are aware it won't be an easy task, but you pick your head up and approach the woman. 'Can you tell me more about the plague?' you ask. She doesn't seem to pay you any mind. Try telling her a little more about yourself.."<<endl<<endl;

	//display menu
	cout<<"1) I am a great warrior and I will destroy the undead one by one with brute force.\n2) I am a powerful mage, ready to harness the arcane energies to defeat the undead.\n3) I am a priest. I will use my holy fire to smite the enemy into oblivion.\n4) I am a skilled assassin. With my expertise in traps and poisons, I will defeat the undead."<<endl;

	do
	{
	//prompt for introChoice
	cout<<"Enter your choice: ";
	cin>>introChoice;
	if (introChoice < 1 || introChoice > 4)
		{
		//display invalid
		cout<<"Invalid. Please enter 1, 2, 3, or 4."<<endl<<endl;
		}
	}
	while (introChoice < 1 || introChoice > 4); 
	

	}
		//if statements for introChoice menu
		if (introChoice == 1)
		{
		//display warrior locChoice text
		cout<<"Quickly running her eyes over your body, the woman scoffed. 'Right. Of course. Well, the plague has spread to several surrounding villages. You can't be in four places at once, but if you really want to help, there are roads leading	to each village near the north, south, east, and west exits of our town. Good luck, warrior... you're going to need it.'"<<endl<<endl;

		//display warrior locChoice menu
		cout<<"1) Go North to Lenville - there are currently 300 zombies and counting.\n2) Go South to Medlania - there are currently 1,000 zombies and counting.\n3) Go East to Staland - there are currently 100 zombies and counting.\n4) Go west to Cherak - there are currently 450 zombies and counting."<<endl<<endl;
		
		do
		{
		//prompt for locChoice
		cout<<"Enter your choice: ";
		cin>>locChoice;
		
		if (locChoice < 1 || locChoice > 4)
			{
			//display invalid
			cout<<"Invalid. Please enter 1, 2 , 3 or 4."<<endl<<endl;
			}
		}
		while (locChoice < 1 || locChoice > 4);
		}
		//if statements for locChoice
		if (locChoice == 1)
		{
		score += 50;	

		//display north combatChoice text
		cout<<"Upon your arrival in Lenville, you notice a foul stench violate your sense of smell and begin to evaluate your grim surroundings. Slowly, you begin to examine the homes scattered around the village, your heavy axe ready for combat. After searching for almost an hour, you begin to grow suspicious. Just as you turn to leave the village, you hear a rumble of low growling and grunting. The zombies approach you, dragging their feet and bodies across the dirt. You know what you have to do."<<endl<<endl;

		//display north combatChoice menu
		cout<<"1) Step towards the horde of undead calmly and strike first.\n2) Charge into the group hoping for the best.\n3) Take a defensive approach and wait for them to come before attacking.\n4) RUN FOR IT! You can't do this. Just try not to drown in your own tears."<<endl;

		do
		{
		//prompt for combatChoice
		cout<<"Enter your choice: ";
		cin>>combatChoice;
		
		if (combatChoice < 1 || combatChoice > 4)
			{
			//display invalid
			cout<<"Invalid. Please enter 1, 2, 3, or 4."<<endl<<endl;
			}
		}
		while (combatChoice < 1 || combatChoice > 4);


		//calculate combatChoice points(RANDOM)
		//seed random number generator
		srand(time(NULL));
		//generate a random number from 1-100
		cRandom = rand()%100 + 1; 

		score += coRandom;

		}
		//if statements for combatChoice menu
		if (combatChoice >= 1 && combatChoice <= 4)
		{
		//display finalChoice text
		cout<<"Covered in blood, sweat, and other unidentifiable liquids, you limp back to your own village. An unbearable pain in your thigh seems to be worsening. As you enter the familiar boundaries of your home, you begin searching for your family. You begin to panic, eyes darting around, when nobody is there to greet you. Something is off. Finally, you spot your wife. There's something different about her. 'John...braiiiiiiiins....' she groans. Your eyes well up with tears, it's time to make your final choice."<<endl<<endl;

		//display finalChoice menu
		cout<<"1) Embrace your wife and let her infect you with the plague. Zombie life can't be that bad.\n2) Use all of your remaining strength to kill her. You must protect the greater good.\n3) Surrender yourself to death.\n4) Limp away as fast as you can."<<endl;


		do
		{
		//prompt for finalChoice
		cout<<"Enter your choice: ";
		cin>>finalChoice;
			
		if (finalChoice < 1 || finalChoice > 4)
			{
			//display invalid
			cout<<"Invalid. Please enter 1, 2, 3, or 4."<<endl<<endl;
			}	
		}
		while (finalChoice < 1 || finalChoice > 4);
		}
		//if statements for finalChoice
			if (finalChoice == 1)
				{
				score += 100;
				}

			else if (finalChoice == 2)
				{
				score += 250;
				}
		
			else if (finalChoice == 3)
				{
				score += 50;
				}
			
			else if (finalChoice == 4)
				{
				score += 20;
				}

			else
				{
				//display invalid
				cout<<"Invalid. Please choose 1, 2, 3, or 4."<<endl;
				}
		
			
			
		//display final score
		cout<<"Your final score is: "<<score<<"."<<endl<<endl;
		//open file "highscore.txt" for input
		infile.open("highscore.txt", ios::in);	

		//read in data
		//read in highName
		getline(infile, highName);
		//read in highscore
		infile>>highscore;
		
		
		if (score > highscore)
		{				
		//Display congrats
		cout<<"CONGRATULATIONS!! YOU HAVE BEATEN THE PREVIOUS HIGHSCORE OF "<<highscore<<"!!"<<endl<<endl;
		//Replace old highscore with new highscore
		infile.close();
		
		outfile.open("highscore.txt", ios::out);
		outfile<<firstName<<" "<<score;	

		outfile.close();
		
		}				
		else if (score < highscore)
		{
		//display sorry
		cout<<"Sorry! You didn't beat the highscore. Keep trying!"<<endl<<endl;
		}

		
		else if (locChoice == 2)
		{
		score += 250;	

		//display south combatChoice text
		cout<<"Upon your arrival in Medlania, you notice a foul stench violate your sense of smell and begin to evaluate your grim surroundings. Slowly, you begin to examine the homes scattered around the village, your heavy axe ready for combat. After searching for almost an hour, you begin to grow suspicious. Just as you turn to leave the village, you hear a rumble of low growling and grunting. The zombies approach you, dragging their feet and bodies across the dirt. You know what you have to do."<<endl<<endl;

		//display south combatChoice menu
		cout<<"1) Step towards the horde of undead calmly and strike first.\n2) Charge into the group hoping for the best.\n3) Take a defensive approach and wait for them to come before attacking.\n4) RUN FOR IT! You can't do this. Just try not to drown in your own tears."<<endl;

		do
		{
		//prompt for combatChoice
		cout<<"Enter your choice: ";
		cin>>combatChoice;
				
		if (combatChoice < 1 || combatChoice > 4)
			{
			//display invalid
			cout<<"Invalid. Please enter 1, 2, 3, or 4."<<endl<<endl;
			}
		}
		while (combatChoice < 1 || combatChoice > 4);

		//calculate combatChoice points(RANDOM)
		//seed random number generator
		srand(time(NULL));
		//generate a random number from 1-100
		cRandom = rand()%100 + 1; 

		score += coRandom;
		}
		//if statements for combatChoice menu
		if (combatChoice >= 1 && combatChoice <= 4)
		{
		//display finalChoice text
		cout<<"Covered in blood, sweat, and other unidentifiable liquids, you limp back to your own village. An unbearable pain in your thigh seems to be worsening. As you enter the familiar boundaries of your home, you begin searching for your family. You begin to panic, eyes darting around, when nobody is there to greet you. Something is off. Finally, you spot your wife. There's something different about her. 'John...braiiiiiiiins....' she groans. Your eyes well up with tears, it's time to make your final choice."<<endl<<endl;

		//display finalChoice menu
		cout<<"1) Embrace your wife and let her infect you with the plague. Zombie life can't be that bad.\n2) Use all of your remaining strength to kill her. You must protect the greater good.\n3) Surrender yourself to death.\n4) Limp away as fast as you can."<<endl;


		do
		{
		//prompt for finalChoice
		cout<<"Enter your choice: ";
		cin>>finalChoice;
		if (finalChoice < 1 || finalChoice > 4)
			{
			//display invalid
			cout<<"Invalid. Please enter 1, 2, 3, or 4."<<endl<<endl;
			}
		}
		while (finalChoice < 1 || finalChoice > 4);
		}
		//if statements for finalChoice
			if (finalChoice == 1)
				{
				score += 100;
				}
				
			else if (finalChoice == 2)
				{
				score += 250;
				}
			
			else if (finalChoice == 3)
				{
				score += 50;
				}
		
			else if (finalChoice == 4)
				{
				score += 20;
				}

			else
			{
			//display invalid
			cout<<"Invalid. Please enter 1, 2, 3, or 4."<<endl<<endl;
			}
		
		//display final score
		cout<<"Your final score is: "<<score<<"."<<endl<<endl;
		//open file "highscore.txt" for input
		infile.open("highscore.txt", ios::in);	

		//read in data
		//read in highName
		getline(infile, highName);
		//read in highscore
		infile>>highscore;

		if (score > highscore)
		{
		//Display congrats
		cout<<"CONGRATULATIONS!! YOU HAVE BEATEN THE PREVIOUS HIGHSCORE OF"<<highscore<<"!!"<<endl<<endl;
		//Replace old highscore with new highscore
		infile.close();

		outfile.open("highscore.txt", ios::out);
			
		outfile<<firstName<<" "<<score;
			
		outfile.close();
		}
		else if (score < highscore)
		{
		//display sorry
		cout<<"Sorry! You didn't beat the highscore! Keep trying!"<<endl<<endl;
		}

		
		
		
		else if (locChoice == 3)
		{
		score += 20;

		//display east combatChoice text
		cout<<"Upon your arrival in Staland, you notice a foul stench violate your sense of smell and begin to evaluate your grim surroundings. Slowly, you begin to examine the homes scattered around the village, your heavy axe ready for combat. After searching for almost an hour, you begin to grow suspicious. Just as you turn to leave the village, you hear a rumble of low growling and grunting. The zombies approach you, dragging their feet and bodies across the dirt. You know what you have to do."<<endl<<endl;

		//display east combatChoice menu
		cout<<"1) Step towards the horde of undead calmly and strike first.\n2) Charge into the group hoping for the best.\n3) Take a defensive approach and wait for them to come before attacking.\n4) RUN FOR IT! You can't do this. Just try not to drown in your own tears."<<endl;


		do
		{
		//prompt for combatChoice
		cout<<"Enter your choice: ";
		cin>>combatChoice;
		if (combatChoice < 1 || combatChoice > 4)
			{
			//display invalid
			cout<<"Invalid. Please enter 1, 2, 3, or 4."<<endl<<endl;
			}
		}
		while (combatChoice < 1 || combatChoice > 4);

		//calculate combatChoice points(RANDOM)
		//seed random number generator
		srand(time(NULL));
		//generate random number 1-100
		coRandom = rand()%100 + 1;  

		score += coRandom;
		}
		//if statements for combatChoice menu
		if (combatChoice >= 1 && combatChoice <= 4)
		{
		//display finalChoice text
		cout<<"Covered in blood, sweat, and other unidentifiable liquids, you limp back to your own village. An unbearable pain in your thigh seems to be worsening. As you enter the familiar boundaries of your home, you begin searching for your family. You begin to panic, eyes darting around, when nobody is there to greet you. Something is off. Finally, you spot your wife. There's something different about her. 'John...braiiiiiiiins....' she groans. Your eyes well up with tears, it's time to make your final choice."<<endl<<endl;

		//display finalChoice menu
		cout<<"1) Embrace your wife and let her infect you with the plague. Zombie life can't be that bad.\n2) Use all of your remaining strength to kill her. You must protect the greater good.\n3) Surrender yourself to death.\n4) Limp away as fast as you can."<<endl;


		do
		{
		//prompt for finalChoice
		cout<<"Enter your choice: ";
		cin>>finalChoice;
			
		if (finalChoice < 1 || finalChoice > 4)
			{
				//display invalid
			cout<<"Invalid. Please enter 1, 2, 3, or 4."<<endl<<endl;
			}
		}
		while (finalChoice < 1 || finalChoice > 4);
			
		}	
		//if statements for finalChoice
			if (finalChoice == 1)
				{
				score += 100;
				}

			else if (finalChoice == 2)
				{
				score += 250;
				}
		
			else if (finalChoice == 3)
				{
				score += 50;
				}
		
			else if (finalChoice == 4)
				{
				score += 20;
				}


		//display final score
		cout<<"Your final score is "<<score<<"."<<endl<<endl;
		//open file "highscore.txt" for input
		infile.open("highscore.txt", ios::in);

		//read in data
		//read in highName
		getline(infile, highName);
		//read in highscore
		infile>>highscore;	
			
		if (score > highscore)
		{
		//Display congrats
		cout<<"CONGRATULATIONS!! YOU HAVE BEATEN THE PREVIOUS HIGH SCORE OF "<<score<<"!!"<<endl<<endl;
		//Replace old highscore with new highscore
		infile.close();

		outfile.open("highscore.txt", ios::out);
		outfile<<firstName<<" "<<score;



		outfile.close();
		}
		else if (score < highscore)
		{
		//display sorry
		cout<<"Sorry! You didn't beat the highscore! Keep trying!"<<endl<<endl;
		}
		
		
		else if (locChoice == 4)
		{
		score += 100;

		//display west combatChoice text
		cout<<"Upon your arrival in Cherak, you notice a foul stench violate your sense of smell and begin to evaluate your grim surroundings. Slowly, you begin to examine the homes scattered around the village, your heavy axe ready for combat. After searching for almost an hour, you begin to grow suspicious. Just as you turn to leave the village, you hear a rumble of low growling and grunting. The zombies approach you, dragging their feet and bodies across the dirt. You know what you have to do."<<endl<<endl;

		//display west combatChoice menu
		cout<<"1) Step towards the horde of undead calmly and strike first.\n2) Charge into the group hoping for the best.\n3) Take a defensive approach and wait for them to come before attacking.\n4) RUN FOR IT! You can't do this. Just try not to drown in your own tears."<<endl;


		do
		{
		//prompt for combatChoice
		cout<<"Enter your choice: ";
		cin>>combatChoice;
		
		if (combatChoice < 1 || combatChoice > 4)
			{
			//display invalid
			cout<<"Invalid. Please enter 1, 2, 3, or 4."<<endl<<endl;
			}
		}
		while (combatChoice < 1 || combatChoice > 4);

		//calculate combatChoice points(RANDOM)
		//seed random number generator
		srand(time(NULL));
		//generate random number 1-100
		coRandom = rand()%100 + 1;

		score += coRandom;
		}
		//if statements for combatChoice menu
		if (combatChoice >= 1 && combatChoice <= 4)
			{
		//display finalChoice text
		cout<<"Covered in blood, sweat, and other unidentifiable liquids, you limp back to your own village. An unbearable pain in your thigh seems to be worsening. As you enter the familiar boundaries of your home, you begin searching for your family. You begin to panic, eyes darting around, when nobody is there to greet you. Something is off. Finally, you spot your wife. There's something different about her. 'John...braiiiiiiiins....' she groans. Your eyes well up with tears, it's time to make your final choice."<<endl<<endl;

		//display finalChoice menu
		cout<<"1) Embrace your wife and let her infect you with the plague. Zombie life can't be that bad.\n2) Use all of your remaining strength to kill her. You must protect the greater good.\n3) Surrender yourself to death.\n4) Limp away as fast as you can."<<endl;


		do
		{
		//prompt for finalChoice
		cout<<"Enter your choice: ";
		cin>>finalChoice;
			
		if (finalChoice < 1 || finalChoice > 4)
			{
			//display invalid
			cout<<"Invalid. Please enter 1, 2, 3, or 4."<<endl<<endl;
			}
		}
		while (finalChoice < 1 || finalChoice > 4);
		}
		//if statements for finalChoice
			if (finalChoice == 1)
				{
				score += 100;
				}
			
			else if (finalChoice == 2)
				{
				score += 250;
				}

			else if (finalChoice == 3)
				{
				score += 50;
				}
		
			else if (finalChoice == 4)
				{
				score += 20;
				}

			else
				{
				//display invalid
				cout<<"Invalid. Please enter 1, 2, 3, or 4."<<endl<<endl;
				}

		//display final score
		cout<<"Your final score is "<<score<<"."<<endl<<endl;
			
		//open file "highscore.txt" for input
		infile.open("highscore.txt", ios::in);

		//read in data
		//read in highName
		getline(infile, highName);
		//read in highscore
		cin>>highscore;

		if (score > highscore)
		{
		//Display congrats
		cout<<"CONGRATULATIONS!! YOU HAVE BEATEN THE PREVIOUS HIGHSCORE OF "<<highscore<<"!!"<<endl<<endl;
		//Replace old highscore with new highscore
		infile.close();
		
		outfile.open("highscore.txt", ios::out);
			
		outfile<<firstName<<" "<<score;


		outfile.close();
		}
		else if (score < highscore)
		{
		//display sorry
		cout<<"Sorry! You didn't beat the highscore. Keep trying."<<endl<<endl;
		}
		
			else if (introChoice == 2)
			{
			//display mage locChoice text
			cout<<"Quickly running her eyes over your body, the woman scoffed. 'Right. Of course. Well, the plague has spread to several surrounding villages. You can't be in four places at once, but if you really want to help, there are roads leading	to each village near the north, south, east, and west exits of our town. Good luck, mage... you're going to need it.'"<<endl<<endl;

			//display mage locChoice menu
			cout<<"1) Go North to Lenville - there are currently 300 zombies and counting.\n2) Go South to Medlania - there are currently 1,000 zombies and counting.\n3) Go East to Staland - there are currently 100 zombies and counting.\n4) Go west to Cherak - there are currently 450 zombies and counting."<<endl;

			do
			{
			//prompt for locChoice
			cout<<"Enter your choice: ";
			cin>>locChoice;
			
			if (locChoice < 1 || locChoice > 4)
				{
				//display invalid
				cout<<"Invalid. Please enter 1, 2, 3, or 4."<<endl<<endl;
				}
			}
			while (locChoice < 1 || locChoice > 4);

			}
			//if statements for locChoice
			if (locChoice == 1)
			{
			score += 50;

			//display north combatChoice text
			cout<<"Upon your arrival in Lenville, you notice a foul stench violate your sense of smell and begin to evaluate your grim surroundings. Slowly, you begin to examine the homes scattered around the village, your arcane powers ready for combat. After searching for almost an hour, you begin to grow suspicious. Just as you turn to leave the village, you hear a rumble of low growling and grunting. The zombies approach you, dragging their feet and bodies across the dirt. You know what you have to do."<<endl<<endl;

			//display north combatChoice menu
			cout<<"1) Step towards the horde of undead calmly and strike first.\n2) Charge into the group hoping for the best.\n3) Take a defensive approach and wait for them to come before attacking.\n4) RUN FOR IT! You can't do this. Just try not to drown in your own tears."<<endl;

			do
			{
			//prompt for combatChoice
			cout<<"Enter your choice: ";
			cin>>combatChoice;
			if (combatChoice < 1 || combatChoice > 4)
				{
				//display invalid
				cout<<"Invalid. Please enter 1, 2, 3, or 4."<<endl<<endl;
				}
			}
			while (combatChoice < 1 || combatChoice > 4);

			//calculate combatChoice points(RANDOM)
			//seed random number generator
			srand(time(NULL));
			//generate random number 1-100
			coRandom = rand()%100 + 1;

			score += coRandom;
			}	
			//if statements for combatChoice menu
			if (combatChoice >= 1 && combatChoice <= 4)
			{
			//display finalChoice text
			cout<<"Covered in blood, sweat, and other unidentifiable liquids, you 	limp back to your own village. An unbearable pain in your thigh seems to be worsening. As you enter the familiar boundaries of your home, you begin searching for your family. You begin to panic, eyes darting around, when nobody is there to greet you. Something is off. Finally, you spot your wife. There's something different about her. 'John...braiiiiiiiins....' she groans. Your eyes well up with tears, it's time to make your final choice."<<endl<<endl;

			//display finalChoice menu
			cout<<"1) Embrace your wife and let her infect you with the plague. Zombie life can't be that bad.\n2) Use all of your remaining strength to kill her. You must protect the greater good.\n3) Surrender yourself to death.\n4) Limp away as fast as you can."<<endl;


			do
			{
			//prompt for finalChoice
			cout<<"Enter your choice: ";
			cin>>finalChoice;
				
			if (finalChoice < 1 || finalChoice > 4)
				{
				//display invalid
				cout<<"Invalid. Please enter 1, 2, 3, or 4."<<endl<<endl;
				}
			}
			while (finalChoice < 1 || finalChoice > 4);
			}	
			//if statements for finalChoice
				if (finalChoice == 1)
					{
					score += 100;
					}

				else if (finalChoice == 2)
					{
					score += 250;
					}

				else if (finalChoice == 3)
					{
					score += 50;
					}

				else if (finalChoice == 4)
					{
					score += 20;
					}

				else
					{
					//display invalid
					cout<<"Invalid. Please enter 1, 2, 3, or 4."<<endl<<endl;
					}	
					
			//display final score
			cout<<"Your final score is "<<score<<"."<<endl<<endl;
			//open file "highscore.txt" for input
			infile.open("highscore.txt", ios::in);

			//read in data
			//read in highName
			getline(infile, highName);
			//read in highscore
			infile>>highscore;

			if (score > highscore)
			{
			//Display congrats
			//Replace old highscore with new highscore
			infile.close();

			outfile.open("highscores.txt", ios::out);
			outfile<<firstName<<" "<<score;

			outfile.close();
				
			}
			else if (score < highscore)
			{
			//display sorry
			cout<<"Sorry! You didn't beat the high score. Keep trying!"<<endl<<endl;
			}
			
			else if (locChoice == 2)
			{
			score += 250;

			//display south combatChoice text
			cout<<"Upon your arrival in Medlania, you notice a foul stench violate your sense of smell and begin to evaluate your grim surroundings. Slowly, you begin to examine the homes scattered around the village, your arcane powers ready for combat. After searching for almost an hour, you begin to grow suspicious. Just as you turn to leave the village, you hear a rumble of low growling and grunting. The zombies approach you, dragging their feet and bodies across the dirt. You know what you have to do."<<endl<<endl;

			//display south combatChoice menu
			cout<<"1) Step towards the horde of undead calmly and strike first.\n2) Charge into the group hoping for the best.\n3) Take a defensive approach and wait for them to come before attacking.\n4) RUN FOR IT! You can't do this. Just try not to drown in your own tears."<<endl;


			do
			{
			//prompt for combatChoice
			cout<<"Enter your choice: ";
			cin>>combatChoice;
			
			if (combatChoice < 1 || combatChoice > 4)
				{
				//display invalid
				cout<<"Invalid. Please enter 1, 2, 3, or 4."<<endl<<endl;
				}
			}
			while (combatChoice < 1 || combatChoice > 4);

			//calculate combatChoice points(RANDOM)
			//seed random number generator
			srand(time(NULL));
			//generate random number 1-100
			coRandom = rand()%100 + 1;

			score += coRandom;
			}
			//if statements for combatChoice menu
			if (combatChoice >= 1 && combatChoice <= 4)
			{
			//display finalChoice text
			cout<<"Covered in blood, sweat, and other unidentifiable liquids, you limp back to your own village. An unbearable pain in your thigh seems to be worsening. As you enter the familiar boundaries of your home, you begin searching for your family. You begin to panic, eyes darting around, when nobody is there to greet you. Something is off. Finally, you spot your wife. There's something different about her. 'John...braiiiiiiiins....' she groans. Your eyes well up with tears, it's time to make your final choice."<<endl<<endl;

			//display finalChoice menu
			cout<<"1) Embrace your wife and let her infect you with the plague. Zombie life can't be that bad.\n2) Use all of your remaining strength to kill her. You must protect the greater good.\n3) Surrender yourself to death.\n4) Limp away as fast as you can."<<endl;


			do
			{
			//prompt for finalChoice
			cout<<"Enter your choice: ";
			cin>>finalChoice;
				
			if (finalChoice < 1 || finalChoice > 4)
				{
				//display invalid
				cout<<"Invalid. Please enter 1, 2, 3, or 4."<<endl<<endl;
				}
			}
			while (finalChoice < 1 || finalChoice > 4);
			}
			//if statements for finalChoice
				if (finalChoice == 1)
					{
					score += 100;
					}

				else if (finalChoice == 2)
					{
					score += 250;
					}

				else if (finalChoice == 3)
					{
					score += 50;
					}
			
				else if (finalChoice == 4)
					{
					score += 20;
					}

				else
					{
					//display invalid
					cout<<"Invalid. Please enter 1, 2, 3, and 4."<<endl<<endl;
					}

			//display final score
			//open file "highscore.txt" for input
			infile.open("highscore.txt", ios::in);

			//read in data
			//read in highName
			getline(infile, highName);
			//read in highscore
			infile>>highscore;

			if (score > highscore)
			{
			//Display congrats
			cout<<"CONGRATULATIONS!! YOU BEAT THE PREVIOUS HIGHSCORE OF "<<highscore<<"!!"<<endl<<endl;

			//Replace old highscore with new highscore
			infile.close();
			
			outfile.open("highscore.txt", ios::out);

			outfile<<firstName<<" "<<score;

			
			outfile.close();					
			}
			else if (score < highscore)
			{
			//display sorry
			cout<<"Sorry! You didn't beat the highscore. Keep trying!"<<endl<<endl;
			}

			
			else if (locChoice == 3)
			{
			score += 20;

			//display east combatChoice text
			cout<<"Upon your arrival in Staland, you notice a foul stench violate your sense of smell and begin to evaluate your grim surroundings. Slowly, you begin to examine the homes scattered around the village, your arcane powers ready for combat. After searching for almost an hour, you begin to grow suspicious. Just as you turn to leave the village, you hear a rumble of low growling and grunting. The zombies approach you, dragging their feet and bodies across the dirt. You know what you have to do."<<endl<<endl;

			//display east combatChoice menu
			cout<<"1) Step towards the horde of undead calmly and strike first.\n2) Charge into the group hoping for the best.\n3) Take a defensive approach and wait for them to come before attacking.\n4) RUN FOR IT! You can't do this. Just try not to drown in your own tears."<<endl;

			do
			{
			//prompt for combatChoice
			cout<<"Enter your choice: ";
			cin>>combatChoice;
			
			if (combatChoice < 1 || combatChoice > 4)
				{
				//display invalid
				cout<<"Invalid. Please enter 1, 2, 3, or 4."<<endl<<endl;
				}
			}
			while (combatChoice < 1 || combatChoice > 4);

			//calculate combatChoice points(RANDOM)
			//seed random number generator
			srand(time(NULL));
			//generate random number 1-100
			coRandom = rand()%100 + 1;

			score += coRandom;
			}
			//if statements for combatChoice menu
			if (combatChoice >= 1 && combatChoice <= 4)
			{
			//display finalChoice text
			cout<<"Covered in blood, sweat, and other unidentifiable liquids, you limp back to your own village. An unbearable pain in your thigh seems to be worsening. As you enter the familiar boundaries of your home, you begin searching for your family. You begin to panic, eyes darting around, when nobody is there to greet you. Something is off. Finally, you spot your wife. There's something different about her. 'John...braiiiiiiiins....' she groans. Your eyes well up with tears, it's time to make your final choice."<<endl<<endl;

			//display finalChoice menu
			cout<<"1) Embrace your wife and let her infect you with the plague. Zombie life can't be that bad.\n2) Use all of your remaining strength to kill her. You must protect the greater good.\n3) Surrender yourself to death.\n4) Limp away as fast as you can."<<endl;


			do
			{
			//prompt for finalChoice
			cout<<"Enter choice: ";
			cin>>finalChoice;
			
			if (finalChoice < 1 || finalChoice > 4)
				{
				//display invalid
				cout<<"Invalid. Please enter 1, 2, 3, or 4."<<endl<<endl;
				}
			}
			while (finalChoice < 1 || finalChoice > 4);
			}
			//if statements for finalChoice
				if (finalChoice == 1)
					{
					score += 100;
					}

				else if (finalChoice == 2)
					{
					score += 250;
					}

				else if (finalChoice == 3)
					{
					score += 50;
					}
			
				else if (finalChoice == 4)
					{
					score += 20;
					}

				else
					{
					//display invalid
					cout<<"Invalid. Please enter 1, 2, 3, or 4."<<endl<<endl;			
					}

			//display final score
			cout<<"Your score is "<<score<<"."<<endl<<endl;
			//open file "highscore.txt" for input
			infile.open("highscore.txt", ios::in);

			//read in data
			//read in highName
			getline(infile, highName);
			//read in highscore
			infile>>highscore;

			if (score > highscore)
			{
			//Display congrats
			cout<<"CONGRATULATIONS!! YOU BEAT THE PREVIOUS HIGH SCORE OF "<<highscore<<"!!"<<endl<<endl;

			//Replace old highscore with new highscore
			infile.close();

			outfile.open("highscore.txt", ios::out);

			outfile<<firstName<<" "<<score;

			
			outfile.close();
			}
			else if (score < highscore)
			{
			//display sorry
			cout<<"Sorry! You didn't beat the high score. Keep trying!"<<endl<<endl;
			}


						
			else if (locChoice == 4)
			{
			score += 100;

			//display west combatChoice text
			cout<<"Upon your arrival in Cherak, you notice a foul stench violate your sense of smell and begin to evaluate your grim surroundings. Slowly, you begin to examine the homes scattered around the village, your arcane powers ready for combat. After searching for almost an hour, you begin to grow suspicious. Just as you turn to leave the village, you hear a rumble of low growling and grunting. The zombies approach you, dragging their feet and bodies across the dirt. You know what you have to do."<<endl<<endl;

			//display west combatChoice menu
			cout<<"1) Step towards the horde of undead calmly and strike first.\n2) Charge into the group hoping for the best.\n3) Take a defensive approach and wait for them to come before attacking.\n4) RUN FOR IT! You can't do this. Just try not to drown in your own tears."<<endl;


			do
			{
			//prompt for combatChoice
			cout<<"Enter your choice: ";
			cin>>combatChoice;
			
			if (combatChoice < 1 || combatChoice > 4)
				{
				//display invalid
				cout<<"Invalid. Please enter 1, 2, 3, or 4."<<endl<<endl;
				}
			}
			while (combatChoice < 1 || combatChoice > 4);

			//calculate combatChoice points(RANDOM)
			//seed random number generator
			srand(time(NULL));
			//generate random number 1-100
			coRandom = rand()%100 + 1;

			score += coRandom;
			}
			//if statements for combatChoice menu
			//if combatChoice >= 1 and combatChoice <= 4
			//display finalChoice text
			cout<<"Covered in blood, sweat, and other unidentifiable liquids, you limp back to your own village. An unbearable pain in your thigh seems to be worsening. As you enter the familiar boundaries of your home, you begin searching for your family. You begin to panic, eyes darting around, when nobody is there to greet you. Something is off. Finally, you spot your wife. There's something different about her. 'John...braiiiiiiiins....' she groans. Your eyes well up with tears, it's time to make your final choice."<<endl<<endl;

			//display finalChoice menu
			cout<<"1) Embrace your wife and let her infect you with the plague. Zombie life can't be that bad.\n2) Use all of your remaining strength to kill her. You must protect the greater good.\n3) Surrender yourself to death.\n4) Limp away as fast as you can."<<endl;

				
			do
			{
			//prompt for finalChoice
			cout<<"Enter your choice: ";
			cin>>finalChoice;
				
			if (finalChoice < 1 || finalChoice > 4)
				{
				//display invalid
				cout<<"Invalid. Please enter 1, 2, 3, or 4."<<endl<<endl;
				}
			}
			while (finalChoice < 1 || finalChoice > 4);

			
			//if statements for finalChoice
				if (finalChoice == 1)
					{
					score += 100;
					}

				else if (finalChoice == 2)
					{
					score += 250;
					}

				else if (finalChoice == 3)
					{
					score += 50;
					}
			
				else if (finalChoice == 4)
					{
					score += 20;
					}
				else
					{
					//display invalid
					cout<<"Invalid. Please enter 1, 2, 3, or 4."<<endl<<endl;
					}

			//display final score
			cout<<"Your score is "<<score<<"."<<endl<<endl;
			//open file "highscore.txt" for input
			infile.open("highscore.txt", ios::in);

			//read in data
			//read in highName
			getline(infile, highName);

			//read in highscore
			infile>>highscore;	

			if (score > highscore)
			{
			//Display congrats
			cout<<"CONGRATULATIONS!! YOU HAVE BEATEN THE PREVIOUS HIGHSCORE OF "<<highscore<<"!!"<<endl<<endl;

			//Replace old highscore with new highscore
			infile.close();

			outfile.open("highscore.txt", ios::out);

			outfile<<firstName<<" "<<score;

			outfile.close();
			}	
			else if (score < highscore)
			{
			//display sorry
			cout<<"Sorry! You didn't beat the highscore. Keep trying!"<<endl<<endl;
			}
			

		
				else if (introChoice == 3)
				{
				//display priest locChoice text
				cout<<"Quickly running her eyes over your body, the woman scoffed. 'Right. Of course. Well, the plague has spread to several surrounding villages. You can't be in four places at once, but if you really want to help, there are roads leading to each village near the north, south, east, and west exits of our town. Good luck, priest... you're going to need it.'"<<endl<<endl;

				//display priest locChoice menu
				cout<<"1) Go North to Lenville - there are currently 300 zombies and counting.\n2) Go South to Medlania - there are currently 1,000 zombies and counting.\n3) Go East to Staland - there are currently 100 zombies and counting.\n4) Go west to Cherak - there are currently 450 zombies and counting."<<endl;

				do
				{
				//prompt for locChoice
				cout<<"Enter your choice: ";		
				cin>>locChoice;
				
				if (locChoice < 1 || locChoice > 4)
					{
					//display invalid
					cout<<"Invalid. Please enter 1, 2, 3, or 4."<<endl<<endl;
					}
				}
				while (locChoice < 1 || locChoice > 4);
				}
				//if statements for locChoice
				if (locChoice == 1)
				{
				score += 50;

				//display north combatChoice text
				cout<<"Upon your arrival in Lenville, you notice a foul stench violate your sense of smell and begin to evaluate your grim surroundings. Slowly, you begin to examine the homes scattered around the village, your holy fire ready for combat. After searching for almost an hour, you begin to grow suspicious. Just as you turn to leave the village, you hear a rumble of low growling and grunting. The zombies approach you, dragging their feet and bodies across the dirt. You know what you have to do."<<endl<<endl;

				//display north combatChoice menu
				cout<<"1) Step towards the horde of undead calmly and strike first.\n2) Charge into the group hoping for the best.\n3) Take a defensive approach and wait for them to come before attacking.\n4) RUN FOR IT! You can't do this. Just try not to drown in your own tears."<<endl;

				do
				{
				//prompt for combatChoice
				cout<<"Enter your choice: ";
				cin>>combatChoice;
				
				if (combatChoice < 1 || combatChoice > 4)
					{
					//display invalid
					cout<<"Invalid. Please enter 1, 2, 3, or 4."<<endl<<endl;
					}
				}
				while (combatChoice < 1 || combatChoice > 4);

				//calculate combatChoice points(RANDOM)
				//seed random number generator
				srand(time(NULL));
				//generate random number 1-100
				coRandom = rand()%100 + 1;

				score += coRandom;
				}
				//if statements for combatChoice menu
				if (combatChoice >= 1 && combatChoice <= 4)
				{
				//display finalChoice text
				cout<<"Covered in blood, sweat, and other unidentifiable liquids, you limp back to your own village. An unbearable pain in your thigh seems to be worsening. As you enter the familiar boundaries of your home, you begin searching for your family. You begin to panic, eyes darting around, when nobody is there to greet you. Something is off. Finally, you spot your wife. There's something different about her. 'John...braiiiiiiiins....' she groans. Your eyes well up with tears, it's time to make your final choice."<<endl<<endl;

				//display finalChoice menu
				cout<<"1) Embrace your wife and let her infect you with the plague. Zombie life can't be that bad.\n2) Use all of your remaining strength to kill her. You must protect the greater good.\n3) Surrender yourself to death.\n4) Limp away as fast as you can."<<endl;

				do
				{
				//prompt for finalChoice
				cout<<"Enter your choice: ";
				cin>>finalChoice;
				
				if (finalChoice < 1 || finalChoice > 4)
					{
					//display invalid
					cout<<"Invalid. Please enter 1, 2, 3, or 4."<<endl<<endl;
					}
				}
				while (finalChoice < 1 || finalChoice > 4);

				}
				//if statements for finalChoice
					if (finalChoice == 1)
						{
						score += 100;
						}

					else if (finalChoice == 2)
						{
						score += 250;
						}

					else if (finalChoice == 3)
						{
						score += 50;
						}
				
					else if (finalChoice == 4)
						{
						score += 20;
						}

					else
						{
						//display invalid
						cout<<"Invalid. Please enter 1, 2, 3, or 4."<<endl<<endl;			
						}



				//display final score
				cout<<"Your score is "<<score<<"."<<endl<<endl;

				//open file "highscore.txt" for input
				infile.open("highscore.txt", ios::in);

				//read in data
				//read in highName
				getline(infile, highName);

				//read in highscore
				infile>>highscore;

				if (score > highscore)
				{
				//Display congrats
				cout<<"CONGRATULATIONS!! YOU HAVE BEATEN THE PREVIOUS HIGHSCORE OF "<<highscore<<"!!"<<endl<<endl;
				//Replace old highscore with new highscore
				infile.close();

				outfile.open("highscore.txt", ios::out);

				outfile<<firstName<<" "<<score;

				outfile.close();
				}	
				else if (score < highscore)
				{
				//display sorry
				cout<<"Sorry! You didn't beat the highscore. Keep trying!"<<endl<<endl;
				}

				
				else if (locChoice == 2)
				{
				score += 250;

				//display south combatChoice text
				cout<<"Upon your arrival in Medlania, you notice a foul stench violate your sense of smell and begin to evaluate your grim surroundings. Slowly, you begin to examine the homes scattered around the village, your holy fire ready for combat. After searching for almost an hour, you begin to grow suspicious. Just as you turn to leave the village, you hear a rumble of low growling and grunting. The zombies approach you, dragging their feet and bodies across the dirt. You know what you have to do."<<endl<<endl;

				//display south combatChoice menu
				cout<<"1) Step towards the horde of undead calmly and strike first.\n2) Charge into the group hoping for the best.\n3) Take a defensive approach and wait for them to come before attacking.\n4) RUN FOR IT! You can't do this. Just try not to drown in your own tears."<<endl;

				do
				{
				//prompt for combatChoice
				cout<<"Enter your choice: ";
				cin>>combatChoice;
				
				if (combatChoice < 1 || combatChoice > 4)
					{
					//display invalid
					cout<<"Invalid. Please enter 1, 2, 3, or 4."<<endl<<endl;
					}
				}
				while (combatChoice < 1 || combatChoice > 4);

				//calculate combatChoice points(RANDOM)
				//seed random number generator
				srand(time(NULL));

				//generate random number 1-100
				coRandom = rand()%100 + 1;

				score += coRandom;
				}
				//if statements for combatChoice menu
				if (combatChoice >= 1 && combatChoice <= 4)
				{
				//display finalChoice text
				cout<<"Covered in blood, sweat, and other unidentifiable liquids, you limp back to your own village. An unbearable pain in your thigh seems to be worsening. As you enter the familiar boundaries of your home, you begin searching for your family. You begin to panic, eyes darting around, when nobody is there to greet you. Something is off. Finally, you spot your wife. There's something different about her. 'John...braiiiiiiiins....' she groans. Your eyes well up with tears, it's time to make your final choice."<<endl<<endl;

				//display finalChoice menu
				cout<<"1) Embrace your wife and let her infect you with the plague. Zombie life can't be that bad.\n2) Use all of your remaining strength to kill her. You must protect the greater good.\n3) Surrender yourself to death.\n4) Limp away as fast as you can."<<endl;


				do
				{
				//prompt for finalChoice
				cout<<"Enter your choice: ";
				cin>>finalChoice;
					
				if (finalChoice < 1 || finalChoice > 4)
					{
					//display invalid
					cout<<"Invalid. Please enter 1, 2, 3, or 4."<<endl<<endl;
					}
				}
				while (finalChoice < 1 || finalChoice > 4);
				}
				//if statements for finalChoice
					if (finalChoice == 1)
						{
						score += 100;
						}

					else if (finalChoice == 2)
						{
						score += 250;
						}

					else if (finalChoice == 3)
						{
						score += 50;
						}
				
					else if (finalChoice == 4)
						{
						score += 20;
						}

					else
						{
						//display invalid
						cout<<"Invalid. Please enter 1, 2, 3, or 4."<<endl<<endl;			
						}
				
				//display final score
				cout<<"Your score is "<<score<<"."<<endl<<endl;

				//open file "highscore.txt" for input
				infile.open("highscore.txt", ios::in);	

				//read in data
				//read in highName
				getline(infile, highName);

				//read in highscore
				infile>>highscore;

				if (score > highscore)
				{
				//Display congrats
				cout<<"CONGRATULATIONS!! YOU HAVE BEATEN THE PREVIOUS HIGHSCORE OF "<<highscore<<"!!"<<endl<<endl;

				//Replace old highscore with new highscore
				infile.close();

				outfile.open("highscore.txt", ios::out);

				outfile<<firstName<<" "<<score;	

				outfile.close();
				}
				else if (score < highscore)
				{
				//display sorry
				cout<<"Sorry! You didn't beat the highscore. Keep trying!"<<endl<<endl;	
				}

				
				else if (locChoice == 3)
				{
				score += 20;

				//display east combatChoice text
				cout<<"Upon your arrival in Staland, you notice a foul stench violate your sense of smell and begin to evaluate your grim surroundings. Slowly, you begin to examine the homes scattered around the village, your holy fire ready for combat. After searching for almost an hour, you begin to grow suspicious. Just as you turn to leave the village, you hear a rumble of low growling and grunting. The zombies approach you, dragging their feet and bodies across the dirt. You know what you have to do."<<endl<<endl;

				//display east combatChoice menu
				cout<<"1) Step towards the horde of undead calmly and strike first.\n2) Charge into the group hoping for the best.\n3) Take a defensive approach and wait for them to come before attacking.\n4) RUN FOR IT! You can't do this. Just try not to drown in your own tears."<<endl;


				do
				{
				//prompt for combatChoice
				cout<<"Enter your choice: ";
				cin>>combatChoice;
				
				if (combatChoice < 1 || combatChoice > 4)
					{
					//display invalid
					cout<<"Invalid. Please enter 1, 2, 3, or 4."<<endl<<endl;
					}
				}
				while (combatChoice < 1 || combatChoice > 4);
				
					
				//calculate combatChoice points(RANDOM)
				//seed random number generator
				srand(time(NULL));

				//generate random number 1-100
				coRandom = rand()%100 + 1;

				score += coRandom;
				}
				//if statements for combatChoice menu
				if (combatChoice >= 1 && combatChoice <= 4)
				{
				//display finalChoice text
				cout<<"Covered in blood, sweat, and other unidentifiable liquids, you limp back to your own village. An unbearable pain in your thigh seems to be worsening. As you enter the familiar boundaries of your home, you begin searching for your family. You begin to panic, eyes darting around, when nobody is there to greet you. Something is off. Finally, you spot your wife. There's something different about her. 'John...braiiiiiiiins....' she groans. Your eyes well up with tears, it's time to make your final choice."<<endl<<endl;

				//display finalChoice menu
				cout<<"1) Embrace your wife and let her infect you with the plague. Zombie life can't be that bad.\n2) Use all of your remaining strength to kill her. You must protect the greater good.\n3) Surrender yourself to death.\n4) Limp away as fast as you can."<<endl;


				do
				{
				//prompt for finalChoice
				cout<<"Enter your choice: ";
				cin>>finalChoice;
				
				if (finalChoice < 1 || finalChoice > 4)
					{
					//display invalid
					cout<<"Invalid. Please enter 1, 2, 3, or 4."<<endl<<endl;
					}
				}
				while (finalChoice < 1 || finalChoice > 4);
				}
				//if statements for finalChoice
					if (finalChoice == 1)
						{
						score += 100;
						}

					else if (finalChoice == 2)
						{
						score += 250;
						}

					else if (finalChoice == 3)
						{
						score += 50;
						}
				
					else if (finalChoice == 4)
						{
						score += 20;
						}

					else
						{
						//display invalid
						cout<<"Invalid. Please enter 1, 2, 3, or 4."<<endl<<endl;			
						}


				//display final score
				cout<<"Your score is "<<score<<"."<<endl<<endl;

				//open file "highscore.txt" for input
				infile.open("highscore.txt", ios::in);

				//read in data
				//read in highName
				getline(infile, highName);

				//read in highscore
				infile>>highscore;

				if (score > highscore)
				{
				//Display congrats
				cout<<"CONGRATULATIONS!! YOU HAVE BEATEN THE PREVIOUS HIGH SCORE OF "<<highscore<<"!!"<<endl<<endl;

				//Replace old highscore with new highscore
				infile.close();

				outfile.open("highscore.txt", ios::out);

				outfile<<firstName<<" "<<score;	

				outfile.close();
				}
				else if (score < highscore)
				{
				//display sorry
				cout<<"Sorry! You did not beat the highscore. Keep trying!"<<endl<<endl;
				}

				
							
				else if (locChoice == 4)
				{
				score += 100;

				//display west combatChoice text
				cout<<"Upon your arrival in Cherak, you notice a foul stench violate your sense of smell and begin to evaluate your grim surroundings. Slowly, you begin to examine the homes scattered around the village, your holy fire ready for combat. After searching for almost an hour, you begin to grow suspicious. Just as you turn to leave the village, you hear a rumble of low growling and grunting. The zombies approach you, dragging their feet and bodies across the dirt. You know what you have to do."<<endl<<endl;

				//display west combatChoice menu
				cout<<"1) Step towards the horde of undead calmly and strike first.\n2) Charge into the group hoping for the best.\n3) Take a defensive approach and wait for them to come before attacking.\n4) RUN FOR IT! You can't do this. Just try not to drown in your own tears."<<endl;


				do
				{
				//prompt for combatChoice
				cout<<"Enter your choice: ";
				cin>>combatChoice;
				
				if (combatChoice < 1 || combatChoice > 4)
					{
					//display invalid
					cout<<"Invalid. Please enter 1, 2, 3, or 4."<<endl<<endl;
					}
				}
				while (combatChoice < 1 || combatChoice > 4);

				//calculate combatChoice points(RANDOM)
				//seed random number generator
				srand(time(NULL));

				//generate random number 1-100
				coRandom = rand()%100 + 1;

				score += coRandom;
				}
				//if statements for combatChoice menu
				if (combatChoice >= 1 && combatChoice <= 4)
					{
				//display finalChoice text
				cout<<"Covered in blood, sweat, and other unidentifiable liquids, you limp back to your own village. An unbearable pain in your thigh seems to be worsening. As you enter the familiar boundaries of your home, you begin searching for your family. You begin to panic, eyes darting around, when nobody is there to greet you. Something is off. Finally, you spot your wife. There's something different about her. 'John...braiiiiiiiins....' she groans. Your eyes well up with tears, it's time to make your final choice."<<endl<<endl;

				//display finalChoice menu
				cout<<"1) Embrace your wife and let her infect you with the plague. Zombie life can't be that bad.\n2) Use all of your remaining strength to kill her. You must protect the greater good.\n3) Surrender yourself to death.\n4) Limp away as fast as you can."<<endl;

				do
				{
				//prompt for finalChoice
				cout<<"Enter your choice: ";
				cin>>finalChoice;
				
				if (finalChoice < 1 || finalChoice > 4)
					{
					//display invalid
					cout<<"Invalid. Please enter 1, 2, 3, or 4."<<endl<<endl;
					}
				}
				while (finalChoice < 1 || finalChoice > 4);
				}	
				//if statements for finalChoice
					if (finalChoice == 1)
						{
						score += 100;
						}

					else if (finalChoice == 2)
						{
						score += 250;
						}

					else if (finalChoice == 3)
						{
						score += 50;
						}
				
					else if (finalChoice == 4)
						{
						score += 20;
						}

					else
						{
						//display invalid
						cout<<"Invalid. Please enter 1, 2, 3, or 4."<<endl<<endl;			
						}
				
				//display final score
				cout<<"Your score is "<<score<<"."<<endl<<endl;				

				//open file "highscore.txt" for input
				infile.open("highscore.txt", ios::in);

				//read in data
				//read in highName
				getline(infile, highName);

				//read in highscore
				infile>>highscore;

				if (score > highscore)
				{
				//Display congrats
				cout<<"CONGRATULATIONS!! YOU HAVE BEATEN THE PREVIOUS HIGHSCORE OF "<<highscore<<"!!"<<endl<<endl;

				//Replace old highscore with new highscore
				infile.close();

				outfile.open("highscore.txt", ios::out);

				outfile<<firstName<<" "<<score;

				outfile.close();	
				}
				else if (score < highscore)
				{
				//display sorry
				cout<<"Sorry! You didn't beat the high score. Keep trying!"<<endl<<endl;
				}

					
					else if (introChoice == 4)
					{
					//display assassin locChoice text
					cout<<"Quickly running her eyes over your body, the woman scoffed. 'Right. Of course. Well, the plague has spread to several surrounding villages. You can't be in four places at once, but if you really want to help, there are roads leading to each village near the north, south, east, and west exits of our town. Good luck, assassin... you're going to need it.'"<<endl<<endl;

					//display assassin locChoice menu
					cout<<"1) Go North to Lenville - there are currently 300 zombies and counting.\n2) Go South to Medlania - there are currently 1,000 zombies and counting.\n3) Go East to Staland - there are currently 100 zombies and counting.\n4) Go west to Cherak - there are currently 450 zombies and counting."<<endl<<endl;


					do
					{
					//prompt for locChoice
					cout<<"Enter your choice: ";
					cin>>locChoice;
					
					if (locChoice < 1 || locChoice > 4)
						{
						//display invalid
						cout<<"Invalid. Please enter 1, 2, 3, or 4."<<endl<<endl;
						}
					}
					while (locChoice < 1 || locChoice > 4);		
					}
					//if statements for combatChoice menu
					if (combatChoice >= 1 && combatChoice <= 4)
						{
					//display finalChoice text
					cout<<"Covered in blood, sweat, and other unidentifiable liquids, you limp back to your own village. An unbearable pain in your thigh seems to be worsening. As you enter the familiar boundaries of your home, you begin searching for your family. You begin to	panic, eyes darting around, when nobody is there to greet you. Something is off. Finally, you spot your wife. There's something different about her. 'John...braiiiiiiiins....' she groans. Your eyes well up with tears, it's time to make your final choice."<<endl<<endl;

					//display finalChoice menu
					cout<<"1) Embrace your wife and let her infect you with the plague. Zombie life can't be that bad.\n2) Use all of your remaining strength to kill her. You must protect the greater good.\n3) Surrender yourself to death.\n4) Limp away as fast as you can."<<endl;

					do
					{
					//prompt for finalChoice
					cout<<"Enter your choice: ";
					cin>>finalChoice;
					
					if (finalChoice < 1 || finalChoice > 4)
						{
						//display invalid
						cout<<"Invalid. Please enter 1, 2, 3, or 4."<<endl<<endl;
						}
					}
					while (finalChoice < 1 || finalChoice > 4);
					}
					//if statements for finalChoice
						if (finalChoice == 1)
							{
							score += 100;
							}

						else if (finalChoice == 2)
							{
							score += 250;
							}

						else if (finalChoice == 3)
							{
							score += 50;
							}
					
						else if (finalChoice == 4)
							{
							score += 20;
							}

						else
							{
							//display invalid
							cout<<"Invalid. Please enter 1, 2, 3, or 4."<<endl<<endl;			
							}


					//display final score
					cout<<"Your score is "<<score<<"."<<endl<<endl;

					//open file "highscore.txt" for input
					infile.open("highscore.txt", ios::in);

					//read in data
					//read in highName
					getline(infile, highName);

					//read in highscore
					infile>>highscore;

					if (score > highscore)
					{
					//Display congrats
					cout<<"CONGRATULATIONS!! YOU HAVE BEATEN THE PREVIOUS HIGHSCORE OF "<<highscore<<"!!"<<endl<<endl;

					//Replace old highscore with new highscore
					infile.close();
					
					outfile.open("highscore.txt", ios::out);

					outfile<<firstName<<" "<<score;
					}
					else if (score < highscore)
					{
					//display sorry
					cout<<"Sorry! You didn't beat the highscore. Keep trying!"<<endl<<endl;
					}


					
					//if statements for locChoice
					if (locChoice == 1)
					{
					score += 50;

					//display north combatChoice text
					cout<<"Upon your arrival in Lenville, you notice a foul stench violate your sense of smell and begin to evaluate your grim surroundings. Slowly, you begin to examine the homes scattered around the village, your traps and poisons ready for combat. After searching for almost an hour, you begin to grow suspicious. Just as you turn to leave the village, you hear a rumble of low growling and grunting. The zombies approach you, dragging their feet and bodies across the dirt. You know what you have to do."<<endl<<endl;

					//display north combatChoice menu
					cout<<"1) Step towards the horde of undead calmly and strike first.\n2) Charge into the group hoping for the best.\n3) Take a defensive approach and wait for them to come before attacking.\n4) RUN FOR IT! You can't do this. Just try not to drown in your own tears."<<endl;

					do
					{
					//prompt for combatChoice
					cout<<"Enter your choice: ";
					cin>>combatChoice;
					
					if (combatChoice < 1 || combatChoice > 4)
						{
						//display invalid
						cout<<"Invalid. Please enter 1, 2, 3, or 4."<<endl<<endl;
						}
					}
					while (combatChoice < 1 || combatChoice > 4);

					//calculate combatChoice points(RANDOM)
					//seed random number generator
					srand(time(NULL));

					//generate random number 1-100
					coRandom = rand()%100 + 1;

					score += coRandom;
					}
					//if statements for combatChoice menu
					if (combatChoice >= 1 && combatChoice <= 4)
						{
					//display finalChoice text
					cout<<"Covered in blood, sweat, and other unidentifiable liquids, you limp back to your own village. An unbearable pain in your thigh seems to be worsening. As you enter the familiar boundaries of your home, you begin searching for your family. You begin to panic, eyes darting around, when nobody is there to greet you. Something is off. Finally, you spot your wife. There's something different about her. 'John...braiiiiiiiins....' she groans. Your eyes well up with tears, it's time to make your final choice."<<endl<<endl;

					//display finalChoice menu
					cout<<"1) Embrace your wife and let her infect you with the plague. Zombie life can't be that bad.\n2) Use all of your remaining strength to kill her. You must protect the greater good.\n3) Surrender yourself to death.\n4) Limp away as fast as you can."<<endl;

					do
					{
					//prompt for finalChoice
					cout<<"Enter your choice: ";
					cin>>finalChoice;
						
					if (finalChoice < 1 || finalChoice > 4)
						{
						//display invalid
						cout<<"Invalid. Please enter 1, 2, 3, or 4."<<endl<<endl;
						}
					}
					while (finalChoice < 1 || finalChoice > 4);
					}
					//if statements for finalChoice
						if (finalChoice == 1)
							{
							score += 100;
							}

						else if (finalChoice == 2)
							{
							score += 250;
							}

						else if (finalChoice == 3)
							{
							score += 50;
							}
					
						else if (finalChoice == 4)
							{
							score += 20;
							}

						else
							{
							//display invalid
							cout<<"Invalid. Please enter 1, 2, 3, or 4."<<endl<<endl;			
							}

					//display final score
					cout<<"Your score is "<<score<<"."<<endl<<endl;

					//open file "highscore.txt" for input
					infile.open("highscore.txt", ios::in);	

					//read in data
					//read in highName
					getline(infile, highName);

					//read in highscore
					infile>>highscore;

					if (score > highscore)
					{
					//Display congrats
					cout<<"CONGRATULATIONS!! YOU HAVE BEATEN THE HIGHSCORE OF "<<highscore<<"!!"<<endl<<endl;

					//Replace old highscore with new highscore
					infile.close();

					outfile.open("highscore.txt", ios::out);

					outfile<<firstName<<" "<<score;

					outfile.close();
					}
					else if (score < highscore)	
					{
					//display sorry
					cout<<"Sorry. You didn't beat the high score. Keep trying!"<<endl<<endl;
					}

					
					else if (locChoice == 2)
					{
					score += 250;

					//display south combatChoice text
					cout<<"Upon your arrival in Medlania, you notice a foul stench violate your sense of smell and begin to evaluate your grim surroundings. Slowly, you begin to examine the homes scattered around the village, your traps and poisons ready for combat. After searching for almost an hour, you begin to grow suspicious. Just as you turn to leave the village, you hear a rumble of low growling and grunting. The zombies approach you, dragging their feet and bodies across the dirt. You know what you have to do."<<endl<<endl;

					//display south combatChoice menu
					cout<<"1) Step towards the horde of undead calmly and strike first.\n2) Charge into the group hoping for the best.\n3) Take a defensive approach and wait for them to come before attacking.\n4) RUN FOR IT! You can't do this. Just try not to drown in your own tears."<<endl;

					do
					{
					//prompt for combatChoice
					cout<<"Enter your choice: ";
					cin>>combatChoice;
					
					if (combatChoice < 1 || combatChoice > 4)
						{
						//display invalid
						cout<<"Invalid. Please enter 1, 2, 3, or 4."<<endl<<endl;
						}
					}
					while (combatChoice < 1 || combatChoice > 4);

					//calculate combatChoice points(RANDOM)
					//seed random number generator
					srand(time(NULL));

					//generate random number 1-100
					coRandom = rand()%100 + 1;

					score += coRandom;
					}
					//if statements for combatChoice menu
					if (combatChoice >= 1 && combatChoice <= 4)
						{
					//display finalChoice text
					cout<<"Covered in blood, sweat, and other unidentifiable liquids, you limp back to your own village. An unbearable pain in your thigh seems to be worsening. As you enter the familiar boundaries of your home, you begin searching for your family. You begin to panic, eyes darting around, when nobody is there to greet you. Something is off. Finally, you spot your wife. There's something different about her. 'John...braiiiiiiiins....' she groans. Your eyes well up with tears, it's time to make your final choice."<<endl<<endl;

					//display finalChoice menu
					cout<<"1) Embrace your wife and let her infect you with the plague. Zombie life can't be that bad.\n2) Use all of your remaining strength to kill her. You must protect the greater good.\n3) Surrender yourself to death.\n4) Limp away as fast as you can."<<endl;


					do
					{
					//prompt for finalChoice
					cout<<"Enter your choice: ";
					cin>>finalChoice;
					
					if (finalChoice < 1 || finalChoice > 4)
						{
						//display invalid
						cout<<"Invalid. Please enter 1, 2, 3, or 4."<<endl<<endl;
						}
					}
					while (finalChoice < 1 || finalChoice > 4);
					}
					//if statements for finalChoice
						if (finalChoice == 1)
							{
							score += 100;
							}

						else if (finalChoice == 2)
							{
							score += 250;
							}

						else if (finalChoice == 3)
							{
							score += 50;
							}
					
						else if (finalChoice == 4)
							{
							score += 20;
							}

						else
							{
							//display invalid
							cout<<"Invalid. Please enter 1, 2, 3, or 4."<<endl<<endl;			
							}


					//display final score
					cout<<"Your score is "<<score<<"."<<endl<<endl;

					//open file "highscore.txt" for input
					infile.open("highscore.txt", ios::in);

					//read in data
					//read in highName
					getline(infile, highName);				

					//read in highscore
					infile>>highscore;

					if (score > highscore)
					{
					//Display congrats
					cout<<"CONGRATULATIONS!! YOU HAVE BEATEN THE PREVIOUS HIGHSCORE OF "<<highscore<<"!!"<<endl<<endl;

					//Replace old highscore with new highscore
					infile.close();
					
					outfile.open("highscore.txt", ios::out);

					outfile<<firstName<<" "<<score;
					

					}
					else if (score < highscore)
					{
					//display sorry
					cout<<"Sorry! You did not beat the highscore. Keep trying!"<<endl<<endl;
					}

					
					
					else if (locChoice == 3)
					{
					score += 20;

					//display east combatChoice text
					cout<<"Upon your arrival in Staland, you notice a foul stench violate your sense of smell and begin to evaluate your grim surroundings. Slowly, you begin to examine the homes scattered around the village, your traps and poisons ready for combat. After searching for almost an hour, you begin to grow suspicious. Just as you turn to leave the village, you hear a rumble of low growling and grunting. The zombies approach you, dragging their feet and bodies across the dirt. You know	what you have to do."<<endl<<endl;

					//display east combatChoice menu
					cout<<"1) Step towards the horde of undead calmly and strike first.\n2) Charge into the group hoping for the best.\n3) Take a defensive approach and wait for them to come before attacking.\n4) RUN FOR IT! You can't do this. Just try not to drown in your own tears."<<endl;


					do
					{
					//prompt for combatChoice
					cout<<"Enter your choice: ";
					cin>>combatChoice;
					
					if (combatChoice < 1 || combatChoice > 4)
						{
						//display invalid
						cout<<"Invalid. Please enter 1, 2, 3, or 4."<<endl<<endl;
						}
					}
					while (combatChoice < 1 || combatChoice > 4);

					//calculate combatChoice points(RANDOM)
					//seed random number generator
					srand(time(NULL));			

					//generate random number 1-100
					coRandom = rand()%100 + 1;

					score += coRandom;
					}
					//if statements for combatChoice menu
					if (combatChoice >= 1 && combatChoice <= 4)
						{
					//display finalChoice text
					cout<<"Covered in blood, sweat, and other unidentifiable liquids, you limp back to your own village. An unbearable pain in your thigh seems to be worsening. As you enter the familiar boundaries of your home, you begin searching for your family. You begin to panic, eyes darting around, when nobody is there to greet you. Something is off. Finally, you spot your wife. There's something different about her. 'John...braiiiiiiiins....' she groans. Your eyes well up with tears, it's time to make your final choice."<<endl<<endl;

					//display finalChoice menu
					cout<<"1) Embrace your wife and let her infect you with the plague. Zombie life can't be that bad.\n2) Use all of your remaining strength to kill her. You must protect the greater good.\n3) Surrender yourself to death.\n4) Limp away as fast as you can."<<endl;

					do
					{
					//prompt for finalChoice
					cout<<"Enter your choice: ";
					cin>>finalChoice;
						
					if (finalChoice < 1 || finalChoice > 4)
						{
						//display invalid
						cout<<"Invalid. Please enter 1, 2, 3, or 4."<<endl<<endl;
						}
					}
					while (finalChoice < 1 || finalChoice > 4);
					}
					//if statements for finalChoice
						if (finalChoice == 1)
							{
							score += 100;
							}

						else if (finalChoice == 2)
							{
							score += 250;
							}

						else if (finalChoice == 3)
							{
							score += 50;
							}
					
						else if (finalChoice == 4)
							{
							score += 20;
							}

						else
							{
							//display invalid
							cout<<"Invalid. Please enter 1, 2, 3, or 4."<<endl<<endl;			
							}

					//display final score
					cout<<"Your score is "<<score<<"."<<endl<<endl;

					//open file "highscore.txt" for input
					infile.open("highscore.txt", ios::in);

					//read in data
					//read in highName
					getline(infile, highName);

					//read in highscore
					infile>>highscore;

					if (score > highscore)
					{
					//Display congrats
					cout<<"CONGRATULATIONS!! YOU HAVE BEATEN THE PREVIOUS HIGHSCORE OF "<<highscore<<"!!"<<endl<<endl;

					//Replace old highscore with new highscore
					infile.close();

					outfile.open("highscore.txt", ios::out);

					outfile<<firstName<<" "<<score;

					}
					else if (score < highscore)
					{
					//display sorry
					cout<<"Sorry! You didn't beat the highsocre. Keep trying!"<<endl<<endl;
					}


					
					else if (locChoice == 4)
					{
					score += 100;

					//display west combatChoice text
					cout<<"Upon your arrival in Cherak, you notice a foul stench violate your sense of smell and begin to evaluate your grim surroundings. Slowly, you begin to examine the homes scattered around the village, your traps and poisons ready for combat. After searching for almost an hour, you begin to grow suspicious. Just as you turn to leave the village, you hear a rumble of low growling and grunting. The zombies approach you, dragging their feet and bodies across the dirt. You know what you have to do."<<endl<<endl;

					//display west combatChoice menu
					cout<<"1) Step towards the horde of undead calmly and strike first.\n2) Charge into the group hoping for the best.\n3) Take a defensive approach and wait for them to come before attacking.\n4) RUN FOR IT! You can't do this. Just try not to drown in your own tears."<<endl;


					do
					{
					//prompt for combatChoice
					cout<<"Enter your choice: ";
					cin>>combatChoice;
					
					if (combatChoice < 1 || combatChoice > 4)
						{
						//display invalid
						cout<<"Invalid. Please enter 1, 2, 3, or 4."<<endl<<endl;
						}
					}
					while (combatChoice < 1 || combatChoice > 4);

					//calculate combatChoice points(RANDOM)
					//seed random number generator
					srand(time(NULL));

					//generate random number 1-100
					coRandom = rand()%100 + 1;

					score += coRandom;
					}
					//if statements for combatChoice menu
					if (combatChoice >= 1 && combatChoice <= 4)
					{
					//display finalChoice text
					cout<<"Covered in blood, sweat, and other unidentifiable liquids, you limp back to your own village. An unbearable pain in your thigh seems to be worsening. As you enter the familiar boundaries of your home, you begin searching for your family. You begin to panic, eyes darting around, when nobody is there to greet you. Something is off. Finally, you spot your wife. There's something different about her. 'John...braiiiiiiiins....' she groans. Your eyes well up with tears, it's time to make your final choice."<<endl<<endl;

					//display finalChoice menu
					cout<<"1) Embrace your wife and let her infect you with the plague. Zombie life can't be that bad.\n2) Use all of your remaining strength to kill her. You must protect the greater good.\n3) Surrender yourself to death.\n4) Limp away as fast as you can."<<endl;

					do
					{
					//prompt for finalChoice
					cout<<"Enter your choice: ";
					cin>>finalChoice;
					
					if (finalChoice < 1 || finalChoice > 4)
						{
						//display invalid
						cout<<"Invalid. Please enter 1, 2, 3, or 4."<<endl<<endl;
						}
					}
					while (finalChoice < 1 || finalChoice > 4);
					}
					//if statements for finalChoice
						if (finalChoice == 1)
							{
							score += 100;
							}

						else if (finalChoice == 2)
							{
							score += 250;
							}

						else if (finalChoice == 3)
							{
							score += 50;
							}
					
						else if (finalChoice == 4)
							{
							score += 20;
							}

						else
							{
							//display invalid
							cout<<"Invalid. Please enter 1, 2, 3, or 4."<<endl<<endl;			
							}

					//display final score
					cout<<"Your score is "<<score<<"."<<endl<<endl;

					//open file "highscore.txt" for input
					infile.open("highscore.txt", ios::in);

					//read in data
					//read in highName
					getline(infile, highName);

					//read in highscore
					infile>>highscore;

					if (score > highscore)
					{
					//Display congrats
					cout<<"CONGRATULATIONS!! YOU HAVE BEAT THE PREVIOUS HIGHSCORE OF "<<highscore<<"!!"<<endl<<endl;

					//Replace old highscore with new highscore
					infile.close();

					outfile.open("highscore.txt", ios::out);

					outfile<<firstName<<" "<<score;

					}
					else if (score < highscore)
					{
					//display sorry
					cout<<"Sorry! You didn't beat the highscore. Keep trying!"<<endl<<endl;
					}

	
	
	else if (mainChoice == 3)
	{
	//display goodbye, end game
	cout<<"Thanks for playing! Goodbye."<<endl;
	}


	else
	{
	//display invalid
	cout<<"Invalid. Please enter 1, 2, or 3."<<endl<<endl;
	}

	
	}
	while (mainChoice != 3);


 return 0;
}


Was This Post Helpful? 0
  • +
  • -

#7 jimblumberg   User is offline

  • member icon

Reputation: 5733
  • View blog
  • Posts: 17,568
  • Joined: 25-December 09

Re: Program not working as intended, no syntax error from compiler

Posted 14 March 2012 - 06:38 AM

You need to start breaking your program up into functions now. Using many small functions will allow you to break the program into manageable pieces where you can understand what each small function does. As it is now you will find it difficult to locate the problems, and there are many. One of the problems is in the following snippet:
   do
   {
      //display main menu
      cout<<"1) See Rules\n2) Play Game\n3) Quit\n";

      //prompt for mainChoice
      cout<<"Enter your choice: ";
      cin>>mainChoice;


      //if statements for main menu choice
      if (mainChoice == 1)
      {
         //display rules and story
         cout<<"The plague is upon us. Slowly but surely, 

      }
      else if (mainChoice == 2)
      {
         //begin game
          /////// Remove many lines for clarity.
         //display intro text
            //prompt for introChoice
            cout<<"Enter your choice: ";
            cin>>introChoice;

      }
      //if statements for introChoice menu
      if (introChoice == 1)
      {
         //display warrior locChoice text
         cout<<"Quickly running her eyes over your body, 





Notice how introChoice is being obtained inside the else if for choice 2, then you close the else if after you validate the input. This means that when you select 1 the if(introChoice == 1) will be evaluated, even though you have not yet entered a value for introChoice. You are doing this in quite a few areas.

Another area of concern is that you open and close your files several times, yet you never insure that the files open correctly.

Also when you mix string input (getline()) with numeric input (cin >> number) you will probably start having problems caused by the numeric input leaving the end of line character in the input buffer for getline(), which will take that character and leave consider processing complete.

To see some of your problems with your logic, start by setting a breakpoint at the beginning of your program and single stepping through your program. You should start noticing some of your problems.

But the best way of "fixing" this program will be to immediately start rewriting your program using functions.

Jim
Was This Post Helpful? 2
  • +
  • -

Page 1 of 1