• Post Reply Bookmark Topic Watch Topic
  • New Topic

add a variable after the loop.  RSS feed

 
Ching Ming
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. 


/


 
Campbell Ritchie
Marshal
Posts: 55761
163
  • 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.
 
Knute Snortum
Sheriff
Posts: 4081
112
Chrome Eclipse IDE Java Postgres Database VI Editor
  • 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!