Hello everyone. I wanted to know how I could create a simple time restriction variable. For example making private double hour; not go over 2:59. Basically I don't want someone to be able to input a number greater than :59 in a Jtextfield. I can do a time application, but that takes a while. I just want to find a simple way of doing it. Thanks in advance. This is what the program is suppose to do below. I've already done everything except getting the time to have a restriction.

A parking garage charges a $2.00 minimum fee to park for up to three hours. The garage charges an additional $.50 per hour for each hour or part thereof in excess of three hours. The maximum charge for any given 24 hour period is $10.00. Assume that no car parks for longer than 24 hours at a time. Write an applet that calculates and displays the parking charges for each customer who parked in the garage yesterday. You chould enter in a JTextField the hours parked for each customer. The applet should display the charge for the current customer and should calculate and display the running total of yesterday's receipts. The applet shoud use the method calculateCharges to determine the charge for each customer.

Recommended Answers

All 2 Replies

You could restrict the length of the text field to to chars. Then you could set up a listener event to validate the text field when it looses focus or when they try to submit the form. I can't think of a way to validate the JTextField other than that

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.