View Single Post
Old Apr 5th, 2006, 2:44 AM   #3
nnxion
Programming Guru
 
nnxion's Avatar
 
Join Date: Jun 2005
Location: elemental plane
Posts: 1,429
Rep Power: 5 nnxion is on a distinguished road
Works fine for me, you are not using your variable roundfloor btw
#include <iostream>
#include <string>
#include <cmath>
#include <iomanip>

using namespace std;

void hitEnter();
void order();

string getUserName();

void echoInfo( string userName );
void obtainSizeAndPrice( string userName, int& size, int& price );
void echoInfo( string userName, int size, int price );
void niceFormat();

double getAreaOfPizza( double P_I, int size );
double calculatePizzaPrice( double areaOfPizza, int price );
double round( double pizzaCost );


int main()
{
	order();

	return(0);
}

void hitEnter()
{

	cout << "\n\n\t\t\t*** Hit ENTER to continue ****\n";
	cin.ignore();

	return;
}

void order()
{

	const double P_I = 3.14159;

	string userName;

	int size,
        price;

	double areaOfPizza,
		   pizzaCost,
		   roundFloor,
		   roundPizza;



	userName = getUserName();
    echoInfo ( userName );

	obtainSizeAndPrice( userName, size, price );
	echoInfo( userName, size, price );

	cout << "\n\n\nSince a " <<size << "-inch pizza covers ";
	areaOfPizza = getAreaOfPizza( P_I, size );
	cout << areaOfPizza << " square inches, then at "
	<< price << " cents per square\n" << "inch, the cost is $";


	niceFormat();


	pizzaCost = calculatePizzaPrice( areaOfPizza, price );
	cout << pizzaCost << ". This rounds to $";

	roundPizza = round( pizzaCost );
	cout << roundPizza << "\n" << endl;



	cin.ignore();
}

string getUserName()
{

	string name;

	cout << "\n\nPlease enter your first name and hit ENTER: ";
	cin >> name;
	return name;
}

void echoInfo( string userName )
{
	cout << "\n\n\t Ah, " <<userName << ", so nice to have you joining us";
	cout << " today for some pizza!!\n\n\n";

	hitEnter();
	cin.ignore();
    system( "cls" );

    return;
}

void obtainSizeAndPrice( string userName, int& size, int& price )
{
	cout <<"\n\n\n"<<userName << ", please enter the pizza size (5 - 25 inches in diameter), and price \n" of ingredients (10 - 15 cents per square inch of pizza), like 5 10:  ";
	cin  >> size >> price;

	return;
}

void echoInfo( string userName, int size, int price )
{
	cout << "\n\n\nThanks, " <<userName << ", for selecting a " <<size << "-inch pizza at ";
	cout <<price << " cents per square inch.\n";

	hitEnter();
	cin.ignore();
    system( "cls" );

	return;
}

void niceFormat()
{

	cout.setf(ios::fixed);

	cout.setf(ios::showpoint);

	return;

}

double getAreaOfPizza( double P_I, int size )
{
	return (P_I*(size/2.0)*(size/2.0));
}

double calculatePizzaPrice( double areaOfPizza, int price )
{
	return ((areaOfPizza*price)/100.0);
}

double round( double pizzaCost )
{
	return (floor(pizzaCost + 0.5));
}

EDIT: Nevermind, The Dark answered your question, I automatically removed the couts without having a look at it.
__________________
"Employ your time in improving yourself by other men's writings, so that you shall gain easily what others have labored hard for."
-- Socrates
nnxion is offline   Reply With Quote