Help with function programs

I have the following program that works great, but I don't know how to set it up using a "main" and "function" program using the following specifications:


- Change has one input – an amount of change to be returned between 0 and 99 cents
- Change has four outputs – the number of quarters, dimes, nickels, and cents to be returned.
- Prompt the user in the main function to enter an integer from 0 to 99 corresponding to an amount of change to be returned.
- Call the function in the main program.

-The main program should display the number of quarters, dimes, nickels, and cents to be returned (with descriptive names, such as:
Number of quarters = 2)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include <iostream>
using namespace std;  

int main()
{    
	int quarters, dimes, nickles, pennies;    
	      
	
	cout << "Enter the number of quarters: ";    
	cin  >> quarters;    
	cout << "Enter the number of dimes: ";    
	cin  >> dimes   ;   
	cout << "Enter the number of nickles: ";    
	cin  >> nickles ;   
	cout << "Enter the number of pennies: ";    
	cin  >> pennies ; 
	cout << "\n";      
	
	cout << "Quarters: " << quarters << endl;  
	cout << "Dimes: " << dimes << endl; 
	cout << "Nickels: " << nickles << endl;
	cout << "Pennies: " << pennies << endl;
	cout << "\n";
	
	float money; // amount of money i have    
	money = (quarters * 0.25) + (dimes * 0.10) + (nickles * 0.05) + (pennies * 0.01);     
	
	cout << "Your total is: $"<< money << endl;     
   
    return 0;
}
Last edited on
What do you want your function to do?
Topic archived. No new replies allowed.