You are required to provide an algorithm to operate a cash register that will keep count of all withdrawals and deposits made during a day’s business operation. For simplicity, this cash register will handle notes with the value of $50, $20, $10 and $5 only, and coins with value of $1, 20 cents and 10 cents only. The cash register must know the total of each denomination in the register at the start of the day. At closing time, the cash register must print out the totals of each denomination still in the register; the general total of money that is in the register; the total deposits and the total withdrawals for the day.
Your solution will require the user to enter the starting number of each note and coin present in the register at the start of the day. The algorithm should also request the type of transaction and amount each time. If it is a deposit then the number of each bill and coin needs to be known. In the case of a withdrawal, the operator must calculate the number of each denomination to be taken out of the register. The cash register cannot hold a balance of less than 10 cents. (HINT: totals of everything must be kept at all times)

Recommended Answers

All 3 Replies

What do you need help with?

Have you done any work on it yet on your own? If not I suggest:

1) Think about it a bit on your own. Think about how the program has to flow, what kinds of decisions you will need to make...in general how you will solve the problem. I often find writing things down very helpful during this process -- flowchart or use pseudocode if you have to...

2) Once you have thought about it (or not), post back here with more specific issues. I mean, sure I could go through and solve the problem for you, but wheres the fun/learning in that? Try it on your own first, that way you will have more understanding of the problem and we can go from there.

(Of course if you already have, then just post back with more specific concerns :) )

i am studying programming design in 5 days...i do not know anythings about c++....it is too hard for me now...i have to write pseudoce for it....but i do not know how to do that....can you help me?

i am studying programming design in 5 days...

What do you mean? You are trying to learn a language in 5 days? You have 5 days until an exam? You are preparing for something? I don't follow....Saying you are studying programming design could refer to a lot of different things, and saying you are studying it in 5 days (if you mean you are trying to learn it in 5 days) is almost absurd...Please clarify

i do not know anythings about c++....it is too hard for me now...

Is C++ your first programming language? If so, it would be understandably hard. Regardless, I would almost suggest learning a different language if you are just learning programming, because I personally don't feel C++ is the best "starter" language. Then again, you don't need to get to the more advanced parts of the language until you have a firm grasp on the basic syntax and semantics, so don't let me disuade you from learning if you are set on learning it.

In any case, there are TONS of tutorials (both on the Internet -- google -- and likely on this site as well, and in books and such) that range from basic in material to advanced or expert. So there are lots and lots of resources to help you learn. And since you are just learning, I would definitely recommend you start easy and follow some beginner tutorials.

i have to write pseudoce for it....but i do not know how to do that....can you help me?

pseudocode is not really programming "code". It's like a high-level, english (or I suppose it could be any language) translation of what it is your program will be doing. It's like programming with no particular syntax. The beauty of pseudocode is that, once you've solved a problem and written it in pseudocode, translating the pseudocode into program code is a simple matter of syntax. That is, if you write a program in pseudocode, you can basically then pick and choose how you want to implement it (in what language, etc).

So, if you follow me, the purpose of pseudocode is to outline the general solution and program flow to a problem that you intend to code. Once you have the pseudocode written, you can literally pick any language in which to implement it. The other thing is that the pseudocode that I write might be different from the pseudocode that you write (especially if problem/solution is complex), since we are not following similar syntax rules, and might choose to solve the problem in different ways.

So, as an example, lets take the problem you wish to code. It could be implemented in C, C++, Java, C#, Haskell, or Scheme (if you so desired), or any other language you wish. Even though the implementation would look different in each language (since the syntax differs, although C, C++, Java, and C# are all very similar), the pseudocode would be the exact same (or very very similar), since each program would be doing the same general thing.

Again, there are tons of examples and resources out there, just do a quick google search...

But, I'll give you an example. Suppose we wished to write a program that asked a user for a positive integer, and in turn, it would print out every number from 1 to that integer. The pseudocode might look like (when I actually do pseudocode, I typically use a flowchart as well, so bear with me):

Create integer variable "input" to hold user input.
Ask user for input.
Store user input into variable "input".
Create an integer counter variable "ctr".

loop:  (looping while ctr is less than "input")

output the value of "ctr".
Increment the value of "ctr" by 1.

end loop

And of course you can pretty it up and such, and you will find some people write more in pseudocode than others. The point is, it should be readable, not overboard on the written english (it should be short and sweet in other words), and you should be able to follow the logic of the program.

I know that was long winded, but hopefully you get the idea. If you are studying cs, then you might be asked to submit pseudocode or flowcharts when designing complex programs. And even if you aren't, they can be very helpful if you have a complex problem to solve.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.