• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

car park pre-payment machine simulation

 
lorraine brown
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

please help me. i need to create a simulation of a car park machine which will allow a customer to select hours, accept payment in denominations and return any change due. i am a first year student and have no confidence with java as yet. i would very much appreciate some code snippets and any advice or tips on this subject.
thanx in anticipation
 
Joe Ess
Bartender
Posts: 9337
10
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the JavaRanch, lorraine.
We love to help people, but you have to do your own homework. The only way to build confidence is to accomplish something.
One of the most basic programming skills is breaking a problem into managable pieces. Select one small part of the program, say entering a number of hours and calculating a price, attempt to code something up and if you run into problems, we can talk about your code.
 
lorraine brown
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hey joe

thanx 4 reply.2 be exact, i've got this far on the actual code. i've also done a use case diagram and class diagram. can u tell me where or how i would specify the denomination of coins pls

class CarPark{


int fee=0;
int amountToPay=0;
int Change=0;

public CarPark(int aFee){
fee = aFee;
}

private void results(int amountPaid){
if(amountPaid<fee){
amountToPay=fee-amountPaid;
System.out.println("Amount to pay is " + amountToPay + " pence");

}else if(amountPaid>fee){
Change=amountPaid-fee;
System.out.println("Change is " + Change + "pence ");
}else {
System.out.println("correct amount paid");
}

}
 
Joe Ess
Bartender
Posts: 9337
10
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are you doing this as an applet or as a console app? How are you supposed to do the input of the denominations?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic