furley
asked on
Beginner programmer needs help!!!
I have 2 questions:
1. How do I create a program that reads 2 digits up to 30 digits each, add these integers together, and display the result.
2. How do I write a program that computes the minimum number of coins and bills needed to make change for a purchase? The program will read in an input file that contains 2 numbers, the cost and the tendered amount. It will then calculate the change needed. For example, if the cost is $10.50 and the tendered amount is $20.00, the change will be 1 $5 bill, 4 $1 bills, and 2 quarters.
I'm not expecting code (although that won't hurt). I just need an idea of how to do these problems. Maybe even some pseudo code. Thanks.
1. How do I create a program that reads 2 digits up to 30 digits each, add these integers together, and display the result.
2. How do I write a program that computes the minimum number of coins and bills needed to make change for a purchase? The program will read in an input file that contains 2 numbers, the cost and the tendered amount. It will then calculate the change needed. For example, if the cost is $10.50 and the tendered amount is $20.00, the change will be 1 $5 bill, 4 $1 bills, and 2 quarters.
I'm not expecting code (although that won't hurt). I just need an idea of how to do these problems. Maybe even some pseudo code. Thanks.
What country are you in?
Won't the minimum number of coins and bills needed to make change for a purchace of $10.50 with $20.00 tendered be 1 $5 bill, 2 $2 bills, and 1 50¢ coin?
Won't the minimum number of coins and bills needed to make change for a purchace of $10.50 with $20.00 tendered be 1 $5 bill, 2 $2 bills, and 1 50¢ coin?
ASKER
yeah, this is for homework.
For the first question, how would I do it without using classes?
I'm in Canada. The bills and coins used are $10, $5, $1, 25 cents (quarter), 10 cents (dime), 5 cents (nickel), and 1 cent (penny).
For the first question, how would I do it without using classes?
I'm in Canada. The bills and coins used are $10, $5, $1, 25 cents (quarter), 10 cents (dime), 5 cents (nickel), and 1 cent (penny).
Hehe, you have to be kidding, you want to be able to add integers of that length WITHOUT classes? Ugh, your program is going to be rather messy when it gets done that's all I have to say.
Here is a tip. The integers should be represented using strings. Then, to add them, think of how you do it with pencil and paper. You add them together by adding each pair of digits and carrying if necessary.
Here is a tip. The integers should be represented using strings. Then, to add them, think of how you do it with pencil and paper. You add them together by adding each pair of digits and carrying if necessary.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
>> For the first question, how would I do it without using classes?
furley, your question was posted in the C++ area. C++ is all about classes, they are the only reason for C++'s existence.
furley, your question was posted in the C++ area. C++ is all about classes, they are the only reason for C++'s existence.
Is this for homework or something?