• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Laundrette

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.


 
lowercase baba
Posts: 13089
67
Chrome Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?
 
ray shah
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 13089
67
Chrome Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,

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

Regards

ray
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic