Pizza Cost

Write a program that uses a function to compute the cost of a pizza with given diameter and the number of toppings. Constant will be the cost per toppings and cost per square inch. It will contain a reputable structure as well.
diameter=17
number of toppings=3

//complier directives

#include<iostream>
#include<iomanip>
#include<cmath>
#include<cstdlib>

using namespace std;
//constant identifiers
float const PI=acos(-1);
float const COST_PER_TOPPING=1.25;
float const COST_PER_SQ_IN=.10;

//function prototypes
float ComputePizzaCost(int Diameterf,int NumberOfToppingsf);

//main body

int main ()
{
//local identifiers
int Diameter, NumberOfToppings;
float TotalCost;
char Another='Y';


do
{
cout<<"Please enter the diameter of pizza?:\n";
cin>>Diameter;
cout<<"Please enter the number of Toppings?:\n";
cin>>NumberOfToppings;

//functioncall
TotalCost=ComputePizzaCost(Diameter, NumberOfToppings);


cout<<"Do you have another pizza to process <Y or N>?\t";
cin>>Another;

if((Another=='Y')||(Another=='y'));
{
system("PAUSE");
system("CLS");
}//end of if

}while((Another=='Y')||(Another=='y'));
//end of while
return 0;
}//end of main
//function defination
//function heading
float ComputePizzaCost(int Diameterf, int NumberOfToppingsf)
{
//local identenfiers
float Area,Radius,PieCost, ToppinsCost, TotalCost;

Radius=float(Diameterf)/2;
Area=PI*pow(Radius,2);
PieCost=Area*COST_PER_SQ_IN;
ToppingsCost=NumberOfToppingsf*COST_PER_TOPPINGS;
TotalCost=PieCost+ToppingsCost;
return TotalCost;
}//end function ComputePizzaCost


I tried to run it but there is something wrong.
Can anyone please help me solve this please.
It would help if you told us what's going wrong so that we know where to start.

-Albatross
after: //functioncall
TotalCost=ComputerPizzaCost(Diameter, NumberOfToppings);

before
cout<<"Do you have another pizza to process<Y or N>?\t";
I think some processing data needs to be there to process an output.
But I don't know what to do?
I'm not sure if I understand you, sorry. What you want to do is output TotalCost, right? In that case, all you need to do is cout it.

-Albatross
it could be this. .in your prototype and the definition the parameters have an f, Diameterf and NumberOfToppingsf.. in the call they don't.. you can try correct that see it it works..
First of all don't forget to put code tags in your code.

Second all you have to do is after:

TotalCost=ComputerPizzaCost(Diameter, NumberOfToppings);

Just add:

std::cout << "Your Pizza costs: " << TotalCost << "\n";


P.S.: Don't use using namespace std; it's bad practice
Thanks I will try and see how it goes.
I am trying to find total cost for pizza and also want to ask if they have any other order to add.
Topic archived. No new replies allowed.