473,508 Members | 2,437 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

coin counting program

2 New Member
Help, im a student that has to write a program for counting coins. Half of the program works but the other half doesn.t

should have the following parameters.

output is:
Name
Date
total number of coins
number of quarters
number of dimes
nickels
pennies

I got all that to work but that math doesnt work

for the Value of the coins and the total coin value, can someone please tell me what im doing wrong?


#include <iostream> //----->Header file
#include <string.h>
#include <math.h>

void main()

{

double quarter_value(0.25);
double dime_value(0.10);
double nickel_value(0.05);
double pennies_value(0.01);

int num_quarters;
int num_dimes;
int num_nickels;
int num_pennies;
int total_num_coins;
int total_val_coins = quarter_value + dime_value + nickel_value + pennies_value;
int total_quarter_val = quarter_value * num_quarters;
int total_dime_val = dime_value * num_dimes;
int total_nickel_val = nickel_value * num_nickels;
int total_pennies_val = pennies_value * num_pennies;

char full_name[32],
date[12];

cout << "Please Enter Your Name: ";
cin >>full_name;
cout <<endl;
cout << "Please Enter Today's Date: ";
cin >>date;
cout <<endl;
cout << "Enter the Number of Quarters: ";
cin >>num_quarters;
cout <<endl;
cout << "Enter the Number of Dimes: ";
cin >>num_dimes;
cout <<endl;
cout << "Enter the Number of Nickels: ";
cin >>num_nickels;
cout <<endl;
cout << "Enter the Number of Pennies: ";
cin >>num_pennies;
cout <<endl;

//Total Number of Coins and Value

//total_num_coins=num_quarters+num_dimes+num_nickels +num_pennies;
//total_val_coins=quarter_value+dime_value+nickel_va lue+pennies_value;

//Total of each coin
//total_quarter_val= quarter_value*num_quarters;
//total_dime_val=dime_value*num_dimes;
//total_nickel_val=nickel_value*num_nickels;
//total_pennies_val=pennies_value*num_pennies;

cout <<"Name:" << full_name <<endl <<endl;

cout <<"Date:" << date <<endl <<endl;

cout <<"Total number of coins input:" << total_num_coins <<endl;
cout <<"Number of Quarters:" << num_quarters <<endl;
cout <<"Number of Dimes:" << num_dimes <<endl;
cout <<"Number of Nickels:" << num_nickels <<endl;
cout <<"Number of Pennies:" << num_pennies <<endl <<endl;

cout <<"Value of Coins:" <<endl;
cout <<"Quarters:" << total_quarter_val <<endl;
cout <<"Dimes:" << total_dime_val <<endl;
cout <<"Nickels:" << total_nickel_val <<endl;
cout <<"Pennies:" << total_pennies_val <<endl <<endl;

cout <<"Total Value of coints:" <<total_val_coins <<endl <<endl;

return 0;
}
May 5 '06 #1
3 16899
mandogon
31 New Member
i got your program working i will send it to you and you can compare the changes that i made to you program




#include <iostream> //----->Header file
#include <string.h>
#include <math.h>
using namespace std;

int main()

{

double quarter_value(0.25);
double dime_value(0.10);
double nickel_value(0.05);
double pennies_value(0.01);

int num_quarters;
int num_dimes;
int num_nickels;
int num_pennies;
int total_num_coins;

double total_quarter_val;
double total_dime_val;
double total_nickel_val;
double total_pennies_val;
double total_val_coins;
char full_name[32],
date[12];

cout << "Please Enter Your Name: ";
cin >>full_name;
cout <<endl;
cout << "Please Enter Today's Date: ";
cin >>date;
cout <<endl;
cout << "Enter the Number of Quarters: ";
cin >>num_quarters;
cout <<endl;
cout << "Enter the Number of Dimes: ";
cin >>num_dimes;
cout <<endl;
cout << "Enter the Number of Nickels: ";
cin >>num_nickels;
cout <<endl;
cout << "Enter the Number of Pennies: ";
cin >>num_pennies;
cout <<endl;

//Total Number of Coins and Value

total_num_coins=num_quarters+num_dimes+num_nickels +num_pennies;
//total_val_coins=quarter_value+dime_value+nickel_va lue+pennies_value;

//Total of each coin
//total_quarter_val= quarter_value*num_quarters;
//total_dime_val=dime_value*num_dimes;
//total_nickel_val=nickel_value*num_nickels;
//total_pennies_val=pennies_value*num_pennies;
//total_val_coins = total_quarter_val + total_dime_val + total_nickel_val + total_pennies_val;
total_val_coins = (quarter_value*num_quarters) + (dime_value*num_dimes) + (nickel_value*num_nickels) + (pennies_value*num_pennies);

cout <<"Name:" << full_name <<endl;

cout <<"Date:" << date <<endl;

cout <<"Total number of coins input:" << total_num_coins <<endl;
cout <<"Number of Quarters:" << num_quarters <<endl;
cout <<"Number of Dimes:" << num_dimes <<endl;
cout <<"Number of Nickels:" << num_nickels <<endl;
cout <<"Number of Pennies:" << num_pennies <<endl <<endl;

cout <<"Value of Coins:" <<endl;
cout <<"Quarters:" << quarter_value*num_quarters <<endl;
cout <<"Dimes:" << dime_value*num_dimes <<endl;
cout <<"Nickels:" << nickel_value*num_nickels <<endl;
cout <<"Pennies:" << pennies_value*num_pennies <<endl <<endl;
cout <<"Total Value of coins:" <<total_val_coins <<endl;
return 0;
}
May 5 '06 #2
viewsonic
2 New Member
[quote=mandogon]i got your program working i will send it to you and you can compare the changes that i made to you program

Thank you so much, funny i was almost there just forgot to do the math, :p
May 6 '06 #3
HerHemi
1 New Member
Hello. I am new to Java and this forum. I have a similar assignment for coin counting....can someone help me?

Create a Java application that prompts a user for a dollar amount (such as 10.34) and then calculates the minimum number of pennies, nickels, dimes, quarters, dollar bills, five dollar bills, ten dollar bills, and twenty dollar bills that are needed to make up that amount. (Using the $10.34 amount, it would take one ten dollar bill; one quarter; one nickel; and four pennies to make up this value.)
May 24 '06 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

0
1638
by: Jon Monteleone | last post by:
Greetings, I posted a few days back and didnt get much of a response, so I figured I would post again with more detail. I am running gnome under fedora core 4. I want a kid to be able to drop a...
12
2832
by: DannyB | last post by:
I'm just learning Python. I've created a simple coin flipper program - here is the code: #Coin flipper import random heads = 0 tails = 0 counter = 0
52
5305
by: celerysoup16 | last post by:
I've written this coin toss program, and can't figure out why it isn't giving accurate results... cheers, Ben #include <stdlib.h> #include <stdio.h> #define H 1 #define T 0 #define SENTINEL...
0
1534
by: coolindienc | last post by:
Honestly, I am totally lost about this program. I don't even know where to start. At first I thought I can ask a user to flip a coin. But then again one will get bored flipping coin fot 100 times....
5
3829
by: sallyk57 | last post by:
I have to make a program that would ask a user for their guess (heads or tails) and tells them if its correct or not then it has to ask the user if they want to play again. I figured out how to do...
6
6060
blackstormdragon
by: blackstormdragon | last post by:
I just started a C++ class and now we're doing loops and have to make a coin flipping program. Well here's mine: #include<iostream> #include<cstdlib> using namespace std; int flip(); void main...
6
6557
by: karafire2003 | last post by:
Hey there i was wondering if someone can help me with my program. I thought i had it down...but i'm having some problems. Here's the assignment. Write a C function named change() that accepts a...
3
2944
by: Jamie88 | last post by:
This program is for a machine wich gives out coins up to the value of £4.99 using the minimun number of coins, but i'm i really having trouble gettin this to work. Any help would really be...
8
24889
by: PAK11 | last post by:
This is what i have so far.......I need to add a function named coin to simulate a coin toss where heads is represented by a 1 and tails a 2. The outcome of the toss should be printed and the result...
0
7321
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7377
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7034
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7488
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
4702
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3191
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3179
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1544
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
412
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.