System pause does not work

I do apologize I couldn't find out how can I put my codes in <> sings:(
Can some one tell me why system("pause") does not work? End of line.

#include <iostream>
using namespace std;

// painting constants
const int SQUARE_FEET = 115;
const int HOURS = 8;
const double LABOR = 18;


// enter number of rooms
int getNumRooms();

// enter price of paint per gallon
double getPaintPrice();

// enter suare feet of each room
int getSquareFeet(int numRooms);


// display results
void displayResults(double paintPrice,int squareFeet);

int main()
{

// print program title
cout << "Program to print a inside of a house" << endl << endl;;

// enter number of rooms
int numRooms = getNumRooms();

// enter price of paint per gallon
double paintPrice = getPaintPrice();

// enter suare feet of each room
double squareFeet = getSquareFeet(numRooms);

// calculate and display results
displayResults(paintPrice,squareFeet);

return 0;
}


// enter number of rooms
int getNumRooms()
{
int numRooms;

do{
cout << "Enter number of rooms: ";
cin >> numRooms;

if(numRooms < 1)
cout << "You must have 1 room" << endl;

}while(numRooms < 1);

return numRooms;
}

// enter price of paint per gallon
double getPaintPrice()
{
double paintPrice;

do{
cout << "Enter price of paint per gallon: ";
cin >> paintPrice;

if(paintPrice < 10)
cout << "Paint cost more than $10.00 per gallon" << endl;

}while(paintPrice < 10);

return paintPrice;
}

// enter suare feet of each room
int getSquareFeet(int numRooms)
{
int totalSquareFeet = 0;
int squareFoot;

for(int i=0;i<numRooms;i++)
{
do{
cout << "Enter square footage for room #" << (i+1) << ": ";
cin >> squareFoot;

if(squareFoot < 1)
cout << "square foot must be greater than 1" << endl;
}while(squareFoot < 1);

totalSquareFeet += squareFoot;
}


return totalSquareFeet;
}



// display results
void displayResults(double paintPrice,int squareFeet)
{

// calculate number of gallons paint required
double gallonsPaint = squareFeet / SQUARE_FEET ;

// calculate hours
int hours = squareFeet / SQUARE_FEET * HOURS;

// calculate paint charges
double paintCost = gallonsPaint * paintPrice;

// calculate labor charge
double charge = hours * LABOR;

// calculate total cost
double totalCost = paintCost + charge;


// print results
cout.setf(ios::fixed);
cout.precision(2);


cout << endl;

// display number of gallons paint required
cout << "number of gallons paint required: " << gallonsPaint << endl;;

// display hours
cout << "hours required: " << hours << endl;

// display paint charges
cout << "paint cost: $" << paintCost << endl;

// display labor charge
cout << "labor charge $" << charge << endl;;

// display total cost
cout << "totalCost: $" << totalCost << endl;
system("pause")
}
Well, its missing a semicolon. I think that it also needs to be in capital letters.

BTW you're watching too much TRON there.

END OF LINE.
Last edited on
Don't you also have to include <cstdlib> or <stdlib.h> for system to work?
On my compiler its standard.
You should never rely on your compiler to do magic things. You should always include the proper include file for the function you are using, in this case <cstdlib>. Just because your compiler includes this file today doesn't mean the next version of the compiler will.
And you would be right.

Thanks for that.
Topic archived. No new replies allowed.