• 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
  • Liutauras Vilda
  • Paul Clapham
Sheriffs:
  • paul wheaton
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Piet Souris
Bartenders:
  • Mike London

add a variable after the loop.

 
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 77295
371
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 7123
184
Eclipse IDE Postgres Database VI Editor Chrome Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic