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_v al = quarter_value * num_quarters;
int total_dime_val = dime_value * num_dimes;
int total_nickel_va l = nickel_value * num_nickels;
int total_pennies_v al = 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_quarter s;
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+n um_dimes+num_ni ckels+num_penni es;
//total_val_coins =quarter_value+ dime_value+nick el_value+pennie s_value;
//Total of each coin
//total_quarter_v al= quarter_value*n um_quarters;
//total_dime_val= dime_value*num_ dimes;
//total_nickel_va l=nickel_value* num_nickels;
//total_pennies_v al=pennies_valu e*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_v al <<endl;
cout <<"Dimes:" << total_dime_val <<endl;
cout <<"Nickels:" << total_nickel_va l <<endl;
cout <<"Pennies:" << total_pennies_v al <<endl <<endl;
cout <<"Total Value of coints:" <<total_val_coi ns <<endl <<endl;
return 0;
}
3 16944
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_v al;
double total_dime_val;
double total_nickel_va l;
double total_pennies_v al;
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_quarter s;
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+n um_dimes+num_ni ckels +num_pennies;
//total_val_coins =quarter_value+ dime_value+nick el_value+pennie s_value;
//Total of each coin
//total_quarter_v al= quarter_value*n um_quarters;
//total_dime_val= dime_value*num_ dimes;
//total_nickel_va l=nickel_value* num_nickels;
//total_pennies_v al=pennies_valu e*num_pennies;
//total_val_coins = total_quarter_v al + total_dime_val + total_nickel_va l + total_pennies_v al;
total_val_coins = (quarter_value* num_quarters) + (dime_value*num _dimes) + (nickel_value*n um_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*n um_quarters <<endl;
cout <<"Dimes:" << dime_value*num_ dimes <<endl;
cout <<"Nickels:" << nickel_value*nu m_nickels <<endl;
cout <<"Pennies:" << pennies_value*n um_pennies <<endl <<endl;
cout <<"Total Value of coins:" <<total_val_coi ns <<endl;
return 0;
}
[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
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.)
Sign in to post your reply or Sign up for a free account.
Similar topics |
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 quarter into a coin slot and get 15 minutes of time on
an account that has "restricted" Internet access via the firefox web browser. We are
experimenting with different ways to allow kids to safely surf the web during school hours
while...
|
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
|
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 -1
|
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. How do I get a computer to flip coin and get result? Any ideas???
Any help will be greatly appreciated greatly!!!!!!!!
Andy
|
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 this but the part that i am stuck on is how to print a summary at the end of this program tracking how many wins and how many losses.
import cs1.Keyboard;
public class CoinToss6
{
public static void main(String args)
{
...
| |
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 ()
{
int coin, counter, tails = 0, heads = 0;
for (counter = 1; counter <= 100; counter++)
|
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 floating point number of total coins and the addresses of the integer variables named quarters, dimes, nickels, and pennies. The function should determine the number of quarters, dimes, nickels, and pennies in the total coins number passed to it and...
|
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 appreciated
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <cmath>
|
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 should be return to the main program. I'm having trouble figuring it out, can anyone please help?
#include <iostream>
using namespace std;
# include <ctime>
int coin();
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
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 then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |