aspose file tools*
The moose likes Beginning Java and the fly likes Laundrette Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Laundrette" Watch "Laundrette" New topic
Author

Laundrette

ray shah
Greenhorn

Joined: Mar 29, 2006
Posts: 3
Hi,

Please can someone help me with this coding. Here is what I am supposed to do

required to code a program that simulates a computer based system
in a launderette. The machines in the launderette use special tickets that users must buy in
order to use the machines
The program should be "menu-driven", and at each menu the user must be allowed to "quit" the
program. The initial (main) menu should look like:
****************************************
1. Pay for drying/washing?
2. Machine status information?
3. Quit?
Enter your option (1, 2 or 3):
****************************************
At option "1" the user should see the following menu:
*****************************************
1) Washing � Extra Large �4.40
2) Washing - Large �3.50
3) Washing - Small �3.10
4) Drying for �1 (25mins) �1.00
5) Drying for 20p (5 mins) �0.20
6) Quit
Enter your option (1, 2, 3, 4, 5 or 6):
*****************************************
Once the user has selected an option they are then prompted for the number of tickets they
require. The user should be allowed to choose more than one option at one go, for instance,
the user should be able to buy tickets for 1 x large wash, 1 x 25-mins drying and 1 x 20p-mins
drying. The machine then calculates the total amount of money required, presents the user
with this total and then requests the amount of money as input. If the user enters too little
money the machine should reject the input and prompt the user to enter again. If the user
enters "6" the machine should return to the main menu.
The machine ONLY accepts pound coins and gives change in the following coin denominations:
� 10 pence
� 20 pence
� 50 pence
The stock of coins in the machine may be assumed unlimited. Once a valid amount of money
has been entered, the machine then calculates the amount of change to return to the user. It
then outputs the amount of each type of coin to the screen. The machine then returns to the
main menu allowing the user to purchase more tickets (if they wish to) before exiting.
At option �2� from the main menu, the "Machine Status information", the user should get an
on-screen report displaying the following information:
� The number of tickets sold to each of the five wash/dry options,
� The number of coins of each denomination returned to the customers, and
� The total amount of money the customers have put into the machine.
These figures are all since the start of this program run, i.e., you do not have to � though you
may - save information between the program runs.


and this is what I have done so far, but I am lost. Please can someone help.


fred rosenberger
lowercase baba
Bartender

Joined: Oct 02, 2003
Posts: 10918
    
  12

Hi Ray!

Welcome to the 'Ranch!

We're happy to help folks around here, but we don't do work for people. Not that you are asking for that, but i'm not sure what you are asking.

does this code compile? run? does it then do what you expect, or not? if not, what does it do differently?

ask as many questions as you want, but make them specific. everyone here is a volunteer, so anything you can do to make it easier on them helps you.

so, what are your questions?


There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
ray shah
Greenhorn

Joined: Mar 29, 2006
Posts: 3
Thank you for getting back to me.

I have complied this in BlueJ and it is syntactically correct, however when I run the program, it loops at some point and I have to reset the machine. I am also not getting a running total of the different options. I also haven't added the money aspect of the program and not sure how to do this, as well as make change. But now I need to add the money aspect as well as. So, I am a uncertain what I should or where I should this.

Does this make any sense?
fred rosenberger
lowercase baba
Bartender

Joined: Oct 02, 2003
Posts: 10918
    
  12

well, if you want to find where it's stuck, you can put in a bunch of print statements. just quickly scanning the code, you're most likely stuck in the while loop. stick a println statement in there, printing what your MenueItem is each time.

look VERY carefully at that loop...

you say "while MenueItem is not three", and then within that loop, you say "if MenueItem is three"

also, what happens if MenueItem gets set to 7?

these are just a few things to think about. i'd reccomend you slow down a little. I get the impression you wrote all this, and are only now starting to test it. Most developers will tell you to work in EXTREMELY short developement cycles. write one or two lines of code, then compile and test until everything is A-OK. then write one more line. that makes it very easy to figure out where things are going wrong.

if you write 80 lines of code, and only then compile and test, it can be VERY hard to find the problems...
ray shah
Greenhorn

Joined: Mar 29, 2006
Posts: 3
Hello,

Thank you for this advise. I will go through this again.

Regards

ray
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Laundrette
 
Similar Threads
adding an auxiliary class to code accesing database
Euler31
Vending Machine.
Vending Machine Project
Vending Machine Project