Question #165079

This function will receive three parameter that will consists of the distance, weight and time in hours.

 

The function must then determine and return the postage cost for that particular distance using the information above and the information on Table 1


Expert's answer

using namespace std;


#define LOCAL	0
#define LONG	1
int determineCost(int d, int w, float h)
{
	int P=0;
	if(d==LOCAL)
	{
		if(w<5) 			P = 125;
		if(w>=5 && w <=20) 	P = 175;
		if(w>20) 			P = 250;
	}
	if(d==LONG)
	{
		if(w<5) 	P = 390;
		if(w>=5) 	P = 450;
	}
	return(P);
}


main(void)
{
	int Wt,Hours,Postage,Dist,Flag=1;
	while(Flag)
	{
		Dist=2;
		while(Dist<LOCAL || Dist>LONG) 
		{
			cout<<"\nEnter Dist (0 for Local and 1 for Long): "; 
			cin>>Dist;
		}
		cout<<"\nEnter Wr. in Kgs.: "; cin>>Wt;
		cout<<"\nEnter Hours      : "; cin>>Hours;
		Postage = determineCost(Dist,Wt,Hours);
		cout<<"\nThe Postage: "<<Postage;
		cout<<"\n\nPress 1 to Continue Or 0 to QUIT: "; cin>>Flag;
	}	
}








Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

LATEST TUTORIALS
APPROVED BY CLIENTS