Help please!

What?? Someone please help me out. I can't grasp any of this stuff. I know what the program should do but don't know how to set it up. This forum is my only means of any help. My instructor is never available and doesn't return calls or emails!!

Assignment:

Write a main function and a function named Coins which operates as follows:
o Change has one input – an amount of change to be returned between 0 and 99 cents
o 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. For example:
Coins(Change, Quarters, Dimes, Nickels, Cents)

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)
at least start it so i can see some code

int main()
{





}
You should first start with some pseudocode

OUTPUT user prompt
INPUT change amount
DIVIDE amount by 25
IF answer >= 1
amount = amount - (25 * answer)
numberOfQuarters = answer
DIVIDE amount by 10
IF answer >= 1
amount = amount - (10 * answer)
numberOfDimes = answer
DIVIDE amount by 5
IF answer >= 1
amount = amount - (5 * answer)
numberOfNickels = answer
DIVIDE amount by 1
IF answer >= 1
amount = amount - (1 * answer)
numberOfPennies = answer


That is pretty much it. Now run through it and make sure it works by using a calculator and testing it and then convert it to code.
Ok. Here is a generic code but how can I put it into a "main" and "function" type program? How do I set up my function program? The main program will out put the return of the function, right? Also this code is getting an error? Any suggestions?

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
#include <iostream>
using namespace std;  

int main()
{    
	int quarters, dimes, nickles, pennies;    
	quarters = dimes = nickles = pennies = 0;      
	
	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 << "Quarters: " << quarters << endl;  
	cout << "Dimes: " << dimes << endl; 
	cout << "Nickels: " << nickles << endl;
	cout << "Pennies: " << pennies << endl;
	
	float money = 0.0; // amount of money i have    
	money = (quarters * .25) + (dimes * .10) + (nickles * .5) + (pennies * .1);     
	
	cout << "you have this amount: "< money << endl;     
   
    return 0;
}
Last edited on
#include <iostream>
using namespace std;

void Coins(int quarters, int dimes, int nickles, int pennies);

int main()
{
int change;
int quarters, dimes, nickles, pennies;

cout <<"Prompt the user in the main function to enter an integer from 0 to 99 corresponding to an amount of change to be returned." << endl;

cin >> change;

Coins(quarters, dimes, nickles, pennies);




cout << "Quarters: " << quarters << endl;
cout << "Dimes: " << dimes << endl;
cout << "Nickels: " << nickles << endl;
cout << "Pennies: " << pennies << endl;

return 0;
}

void Coins(int quarters, int dimes, int nickles, int pennies)
{

int amount;

///////example code
//if(change >= 1)
//amount = amount -(25 * change)
//quarters = change;



IF answer >= 1
amount = amount - (25 * answer)
numberOfQuarters = answer
DIVIDE amount by 10
IF answer >= 1
amount = amount - (10 * answer)
numberOfDimes = answer
DIVIDE amount by 5
IF answer >= 1
amount = amount - (5 * answer)
numberOfNickels = answer
DIVIDE amount by 1
IF answer >= 1
amount = amount - (1 * answer)
numberOfPennies = answer


}
Last edited on
sorta....just fill in code for the function
aaronfue, the code you posted is the exact opposite of you description. I thought you stated that the user enters a change amount and YOU return to them the number of coins.

Why are you asking the user for the number of coins?
Topic archived. No new replies allowed.