Results 1 to 3 of 3
Thread: what is wrong with my code :(
- 03-23-2011, 04:27 AM #1
Member
- Join Date
- Mar 2011
- Posts
- 1
- Rep Power
- 0
what is wrong with my code :(
my project is to:
A parking garage charges a $2.00 minimum fee to park for up to three hours. The garage
charges an additional $0.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 application that calculates and displays the parking charges for each customer
who parked in the garage yesterday. You should enter the hours parked for each customer.
The program should display the charge for the current customer and should calculate and display
the running total of yesterdays receipts. The program should use the method calculateCharges to
determine the charge for each customer.
and so far my code is:
package src;
import java.io.PrintStream;
import java.util.Calendar;
import java.util.Date;
import java.util.Scanner;
public class ParkingCharges {
// Create method to ask for hours parked for each customer
public void getHoursParked() {
double hoursParked;
int customerID;
Scanner input = new Scanner(System.in);
System.out.println("Enter the customer ID: ");
customerID = input.nextInt();
System.out.println("Enter the hours parked: ");
hoursParked = input.nextDouble();
// call the method calculateCharges()
calculateCharges(customerID, hoursParked);
}
// Create method calculateCharges to determine the charge for each customer
public void calculateCharges(int customerID, double hoursParked) {
double chargeFees = 0;
double excessHour=0;
// if within 3 hours, set the charge fees to $2.00
if (hoursParked==3) {
chargeFees = 2.00;
// if more than 3 hours, calculate the minutes that more than 3 hours
// to determine the additional charge fees
} else if (hoursParked>3) {
excessHour = hoursParked-3;
int remHours=(int) (excessHour % 10);
chargeFees=2.00+(0.5*remHours);
// if it is 24-hours, charge fees is $10.00
} else if (hoursParked==24) {
chargeFees = 10.00;
} else {
// additional charge of $0.5 for part thereof excess three hours
chargeFees = 2.5;
}
// call the method of displayCharges
displayCharges(customerID, chargeFees);
} // end of method calculateCharges
// Create a method to displayCharges of the charge calculation
public void displayCharges(int customerID, double chargeFees) {
long oneDay = (long) 1000.0 * 60 * 60 * 24;
Date yesterday = new Date(System.currentTimeMillis() oneDay);
System.out.println(" Parking Fees Calculation System ");
System.out.printf("| Date: %s |", yesterday);
System.out.printf("\n| Customer ID: %d\t\t\t |", customerID);
System.out.printf("\n| Total parking fees: %.2f\t\t |", chargeFees);
System.out.printf("\n-")
} // end of method displayCharges
} // end class ParkingCharges
i am getting an error in my create a method to displayCharges
on the line that reads:
Date yesterday = new Date(System.currentTimeMillis() oneDay);
it says Multiple markers at this line
- Syntax error on token "Invalid Character", ,
expected
- 03-23-2011, 04:35 AM #2
Senior Member
- Join Date
- Aug 2009
- Posts
- 2,388
- Rep Power
- 6
Format your code with proper indentation and use code tags when posting the code.
- 03-23-2011, 04:37 AM #3
Similar Threads
-
what is wrong with my code
By amrmb09 in forum New To JavaReplies: 7Last Post: 02-11-2011, 05:10 PM -
What is wrong with this code?
By Mythreadings in forum New To JavaReplies: 38Last Post: 11-19-2010, 12:43 AM -
what is wrong in dis code?
By jitun2004 in forum New To JavaReplies: 8Last Post: 04-15-2009, 09:30 AM -
what's the wrong in this Code
By the swan in forum AWT / SwingReplies: 1Last Post: 04-04-2009, 04:27 AM -
What is wrong with this code
By rosh72851 in forum New To JavaReplies: 13Last Post: 10-31-2008, 01:50 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks