Honor Code Acknowledgment: _____________________________
Due: Friday, June 4, 1999 7 points
int DoSomething(int a, int & b)
{
a += 1;
b += 3;
return a+b;
}
int DoAgain(int & a, int & b)
{
a += 1;
b += 3;
return a+b;
}
int main()
{
int a = 3, b = 4;
cout << DoSomething(a,b) << endl;
cout << "a= " << a << " b= " << b << endl;
a = 3, b = 4;
cout << DoSomething(b,a) << endl;
cout << "a= " << a << " b= " << b << endl;
a = 3, b = 4;
cout << DoAgain(a,a) << endl;
cout << "a= " << a << " b= " << b << endl;
}
What is the output?
Write the function MakeChange to convert a dollar amount into all coins: quarters, nickels and pennies. Put as much as possible into quarters, then nickels, and then pennies.
For example, MakeChange(4.97, quar, nick, pen) modifies quar to be 19, nick to be 4 and pen to be 2.
Complete the function MakeChange below.
void MakeChange(double amount, int & quarters, int & nickels, int & pennies)
// precondition: amount >= 0 and has at most two decimal places
// postcondition: returns the number of quarters, nickels and pennies
// equal to amount, with preference for quarters first,
// then nickels, and then pennies.
{