sh: PAUSE: command not found error message, not understanding it.

I keep getting an error message when running my code at the end. I think it has something to do with line 26, but I'm not sure how to correct it. the error is
sh: PAUSE: command not found

My code is attached.

Thanks for help in advance.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#include<iostream> 
#include<cmath>

using namespace std;

int CheckWeight(int weight, string Planet);

int main()
{
	int weight,res;
	string planetName;
	
	do{
		cout << "Please enter your weight of your object to the nearest whole number." <<endl;
		cin >> weight;}
	while(cin.good()==false);
	cout << " " << endl;
	do{ 
		cout << "Please enter a planet name from the following list." << endl;
		cout << "Mercury, Venus, Earth, Mars, Jupiter, Saturn, Uranus, Neptune" << endl;
		cin >> planetName;
		cout << " " << endl;
		// Call function to check weight
		res = CheckWeight(weight, planetName);
	}while(res==1);
	system("PAUSE");
	return 0;
}// end main()

// Function for calculating weight

int CheckWeight(int weight, string Planet)
{
	int Result=0;
	if(Planet== "Mercury"){
		cout << "Your weight on Mercury is " << (weight*0.4155)<< endl;
	}
	else if(Planet== "Venus"){
		cout << "Your weight on Venus is " << (weight*0.8975)<< endl;
	}
	else if(Planet== "Earth"){
		cout << "Your weight on Earth is " << (weight*1.0)<< endl;
	}
	else if(Planet== "Mars"){
		cout << "Your weight on Mars is " << (weight*0.3507)<< endl;
	}
	else if(Planet== "Jupiter"){
		cout << "Your weight on Jupiter is " << (weight*2.5374)<< endl;
	}
	else if(Planet== "Saturn"){
		cout << "Your weight on Saturn is " << (weight*1.0677)<< endl;
	}
	else if(Planet== "Uranus"){
		cout << "Your weight on Uranus is " << (weight*0.8947)<< endl;
	}
	else if(Planet== "Neptune"){
		cout << "Your weight on Neptune is " << (weight*1.1794)<< endl;
	}
	else{
		cout << "You entered a wrong planet name. Please try again " << endl;
		cout << "Please try again " << endl;
		Result=1;
	}
	return Result;
Don't use
system("PAUSE");
system("PAUSE");

This instructs your programme to ask the shell it is running inside to execute the command PAUSE, just as if you had typed PAUSE into a command line yourself. Your shell has no such command, and hence returns as error message. As I recall, this command commonly exists in various Windows shells, but is not present in bash, csh, tcsh, fish and a number of other shells that are commonly used in *nix operating systems.

The solution is to step away from this hideous OS-dependent hack and do something actually within your programme if you want to pause the programme.
Try system("read");... Sure, there are better ways than this.
Topic archived. No new replies allowed.