Win a copy of React Cookbook: Recipes for Mastering the React Framework this week in the HTML Pages with CSS and JavaScript forum!
  • 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
  • Ron McLeod
  • Paul Clapham
  • Rob Spoor
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Junilu Lacar
  • Tim Cooke
Saloon Keepers:
  • Tim Holloway
  • Piet Souris
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Frits Walraven
  • Himai Minh

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: 73738
332
  • 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: 7111
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?
 
Space pants. Tiny ad:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic