• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Knute Snortum
  • Bear Bibeault
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Frits Walraven
  • Carey Brown
  • Tim Holloway

add a variable after the loop.

 
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My code asks for a user to pay for their parking. I would like the user have to ability to add money to the program. So right now the code runs through the loop it just states how much money it would cost. I would like the user to have the ability to add money so that the program ends when the totalAmountCollected - amount of the the user ended so that the program will exit when the balance is 0.  


/


 
Marshal
Posts: 64658
225
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please remind yourself how code tags work; I have added them for you this time, otherwise that code would have been illegible.
Why are you using Option Pane for keyboard input? That is very old‑fashioned style.
Why are all your methods marked static?
Why are you multiplying by 1.5 and then casting to an int in line 148?
How do you think you sh‍ould record the amount paid in the parking machine? Do you simply want a running total of what has been paid?
 
Ching Ming
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well I originally thought there would be a question to ask the user at the beginner do you want to add money or buy services. Adding money and buying services would be their own separate loops. But that is first thing I am confused about can this program be done with only loop or two. Thanks.
 
Sheriff
Posts: 6029
157
Eclipse IDE Postgres Database VI Editor Chrome Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You could use one loop for each question... but can you think of a way to use one loop for all prompts and answers?
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!