Given any amount of money expressed in dollars, and cents, this program computes the number of 100 , 50, 20, 10, 5 and 1 dollar bills and number of quarters, dimes, nickels, and pennies to be returned, returning how many of each denomination are included.
How to program it correctly for the most part except I cannot figure out how to handle large numbers, such as 14.49999999999999999999999999999999.
When converting that number to int by multiplying by 100 it returns it as 1450 not 1449. How to handle converting doubles, similar to the one above, to an integer correctly?
This is the code that my teacher did not want, since I handled the input as a string:
#include <iostream>
#include <string>
#include<iomanip>
#include<windows.h>
using namespace std;
Problem:Given any amount of money expressed in dollars, and cents, this program computes the number of 100 , 50, 20, 10, 5 and 1 dollar bills and number of quarters, dimes, nickels, and pennies to be returned, returning how many of each denomination are included.
I figured out how to program it correctly for the most part except I cannot figure out how to handle large numbers, such as 14.49999999999999999999999999999999.When converting that number to int it returns it as 14.50. How to handle converting doubles, similar to the one above, to an integer correctly?
This is the code that my teacher did not want, since I handled the input as a string:
Code: #include <iostream> #include <string> #include<iomanip> #include<windows.h> using namespace std; int main(){ const int hundredsConst=10000, fiftiesConst=5000, twentiesConst=2000, tensConst=1000;
I haven't actually learned how to use arrays yet but I know the basic principle of it and decided to try and implement one to improve my code. I'm sure the thing is a bug ridden mess but I would particularly like to point your attention to the function sortDenomination(). Is what I am trying to do in the loop possible?
The reason why I want to do it this way and not with if statements for each denomination is because I can then easily apply this to the second part of the assignment which sees us split a double into dollars and cents and then process each separately. All I would have to differ for each is change the money_loop variable to include the last two denominations in the array.
Code: #include <stdio.h> /*Reads cents input from the user.*/ void getCents(int &read_cents) { printf("Please enter the amount of cents between 5-95:
I am having some serious issues with class inheritance. I am trying to make a MoneyBag class inherit from a class called bag. This will not work. I get an error complaining: error: expected class-name before '{' token. And yes I have googleing it and tried several of the various solutions offered with no avail.
The MoneyBag is pretty simple right now as I wanted to get it connected to bag before I tried to do anything with it.
//MoneyBag.h//
#ifndef MONEYBAG_H #define MONEYBAG_H #include <bag.h> class MoneyBag : public bag{ ////<<------ Error appears on this line.
[Code] ....
So based on everything I have seen on line the statement: class MoneyBag : public bag{ is legal. As it is done this way on this very site's tutorial: class Rectangle: public Shape, public PaintCost{
I've created a program meant for submission for my final project but when i ran it, it shows that the variable being used without being initialized for quite a few time. My program is below.
I have been given to do a simple ATM project which is containing of getting a number of notes in the ATM (100, 500, 1000). Get the withdrawal of money and show the number of note. Here what i got so far. I may need to use a loop but I am not sure how to put it into this.
#include <stdio.h> #include <conio.h> int main() { int a=10, b=10, c=10; int q;
[Code] ....
But the problem is i don't know how to make the code continue with the process with the amount of notes that is left from the previous input. The program will just stop but i really want it to be able to input new withdrawal amount so that it can decrease the note each time i withdrawal the money.
My coin/money change code works when there can be an exact change each time, i.e. when the 1 cent option is available. However, when the change options are only $10, $5, $1, 25 cents and 10 cents, it does not give me what I want for instance, I wanted to get change for $237.80, I was expecting to get:
23 10's, one 5, two 1's and 8 dimes. However, the code below is giving me 23 10's, one 5, two 1's and 3 quarters (there is no option left for the 5 remaining cents).how to fix it?
Code: #include<iostream> #include<algorithm> #include<vector> using namespace std; void change(double cents, int a[]); int main() { double Dollars; double cents;
I was assigned a problem involving using buffer overflow to access a different function than I was supposed to. I was able to figure out how to modify the point in stack that I need to change using a printf statement, however what doesn't make sense is that when I use the input "AABBCCDDEEFFGGx86x64x00x00" the stack changes to 78363878 I looked up the ascii codes and I assume that it's not converting x86, but using the input x86 instead.
I have written this to convert this .dat file into .txt file but it is not working well. It create one .txt file and also with content but contain some garbage content also .
if we have int x = 5; and we want to convert x which is == 5 to char so for example char number = x doesnot work i understand why , but how to convert it ?
How would you go about converting a decimal value to hex and then do math? Every example of converting decimal to hex that I have seen creates an array and I wouldn't be able to do math if I did that. Something like this.
15 decimal to hex F 17 decimal to hex 11 F hex + 11 hex = 20