How do I pass the user entered distance gathered from one function to another function to calculate a shipping cost? And then show the cost via the int main function?
My distance function
double getDistance(double distance)
{
cout << "Enter the distance to be shipped: (min 10 Mi, max 3000 Mi): ";
cin >> distance;
while(distance<=10 || distance>= 3000){
cout << "We do not ship less than 10 miles or more than 3000 miles,
please reenter: ";
cin >> distance;
}
return distance;
}
I was thinking I could return distance and then use it in another function?? Is that right?
I need the variable distance to calculate the final shipping cost in another function ie calcCost then in the main function int main() simply display it cout << "the cost is " << finalCost << endl;
How do I pass the variable distance to another function to calculate cost and then display the cost via the int main() function?