help with system ("pause"); return 0;

Hello, I am writing a program for class and I feel I have the code worked out well. However when I try to run the code to see if it works, I cannot get it to "pause". I am using system ("pause");
return 0; just as I had in other codes, but today I cannot figure out what is going on. Any help would be appreciated. Thanks

[code]
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>

using namespace std;

//Function prototypes
void showmenu();
void skiNameTime();

int main()
{
double AvgTime = 0.0; //average skier time
int count = 0; //counter
const int size = 5; // global constant
string SkiNames[size] = { "Leela", "Sarah", "Anna", "Keesha", "Heidi" }; //array of skiers
double SkiTimes[size] = { 2.03, 2.40, 1.85, 1.90, 2.50 }; //array of ski times
int choice; //holds choice
const int fast_skier = 1, avg_time = 2, time_skier = 3, list_skier = 4;
string fastSkiName = "Anna";
double fastestTime = 1.85;


//set up output formatting
cout << fixed << showpoint << setprecision(2);

do
{
//display menu
showmenu();
cin >> choice;

//validate the menu selection.
while (choice>5)
{
cout << "Please enter a valid menu choice "<<endl;
cin >> choice;
}

if (choice == fast_skier)
{
cout << "The fastest skier is " << fastSkiName << " with a time of " << fastestTime;

switch (choice)
{
case avg_time:
{
const int size = 5;
double SkiTimes[size];
double total = 0;
double avg;
for (int count = 0; count < size; count++)
total += SkiTimes[size];
avg = total / size;
cout << "The average time is " << avg << endl;
}
break;

case list_skier:
{
cout << "Skiers " << endl;
for (int count = 0; count < size; count++)
cout << SkiNames[size] << endl;
}

case time_skier:
skiNameTime();
break;

}
}
} while (choice < 1 || choice>4);
return 0;
}
//*****************************************************************************
///Definition of function showmenu *
//**********************************

void showmenu()
{
cout << "Enter 1 to determine the fastest skier\n"
<< "Enter 2 to calculate the average time\n"
<< "Enter 3 to find the time of a skier\n"
<< "Enter 4 to display the list of skiers\n"
<< "To exit enter any other number ";
}
//***************************************** ******************************
//Definiton of skiNameTime. This is a list of the skiers names and times *
//************************************************************************

void skiNameTime()
{
cout << "Leela\t" "2.03\n"
<< "Sarah\t" "2.40\n"
<< "Anna\t" "1.85\n"
<< "Keesha\t" "1.90\n"
<< "Heidi\t" "2.50\n";
}
system("pause");
return 0:
}
pause is a windows operating system utility. If you are not on windows it will not work.

Ajenell, please either sort out your code tags or re-post after this with your proper code.

I may have miscounted opening and closing braces, but I doubt if that code will compile. Anyway, put system("pause") at the end of main(), not floating around after a bunch of other routines.
this:
1
2
3
system("pause");
return 0:
}

is not in any function. Additionally, you are asking the user for a number 1-4 but you only have 3 cases and no default.
Topic archived. No new replies allowed.