// demonstrates the call-by-value effect // Walt Savitch // 2/10/00 #include using namespace std; const int RATE = 100; // dollars per quarter hour. int fee(int hours_worked, int minutes_worked); // computes fee int main( ) { int hours, minutes; // time worked int bill;// money to bill // output greeting cout << "Welcome to the offices of\n" << "Dewey, Cheatham, and Howe.\n" << "The law office with a heart.\n" << "Enter the hours and minutes" << " of your consultation:\n"; cin >> hours >> minutes; bill = fee(hours, minutes); // the change in the local parameter of fee does not // affect the value of "minutes" cout << "For " << hours << " hours and " << minutes << " minutes, your bill is $" << bill << endl; } // returns the charges for hours_worked hours and // minutes_worked minutes of legal services. int fee(int hours_worked, int minutes_worked) { int quarter_hours; // local variable // notice the formal parameter changes minutes_worked = hours_worked*60 + minutes_worked; quarter_hours = minutes_worked/15; return (quarter_hours*RATE); }