Answered You can hire a professional tutor to get the answer.

QUESTION

change_quarters, change_dimes, change_nickels and then displaying the corrects amount of pennies in write_change.

Hello there, so I need help figuring out my defined functions for: change_quarters, change_dimes, change_nickels and then displaying the corrects amount of pennies in write_change. I have tired several codes especially with % and cant seem to get what I need.

I need help to get my answer to be this:

Enter change in dollars ($): 1.42

Making change for 142 cents

Quarters: 5

Dimes: 1

Nickels: 1

Pennies: 2

while my answer is this:

Enter change in dollars ($): 1.42

Making change for 142 cents

Quarters: 17

Dimes: 2

Nickels: 2

Pennies: 142

and here is my code:

#include <cstdlib>

#include <iostream>

using namespace std;

// FUNCTION PROTOTYPE FOR read_change

double read_change(); 

// FUNCTION PROTOTYPE FOR convert2cents

int convert2cents(double dollars); 

// FUNCTION PROTOTYPE FOR change_quarters

int change_quarters(int & cents);

// FUNCTION PROTOTYPE FOR change_dimes

int change_dimes(int & cents); 

// FUNCTION PROTOTYPE FOR change_nickels

int change_nickels(int & cents);

// FUNCTION PROTOTYPE FOR write_change

double write_change(double quarters, double dimes, double nickels, double pennies);

int main()

{

 double dollars(0.0);

 int cents(0), quarters(0), dimes(0), nickels(0), pennies(0);

 dollars = read_change();

 cents = convert2cents(dollars);

 cout << endl << "Making change for " << cents << " cents" << endl;

 quarters = change_quarters(cents);

 dimes = change_dimes(cents);

 nickels = change_nickels(cents);

 pennies = cents;

 write_change(quarters, dimes, nickels, pennies);

 return 0;

}

// DEFINE FUNCTION read_change HERE:

double read_change()

{

Show more
LEARN MORE EFFECTIVELY AND GET BETTER GRADES!
Ask a Question