# Thread: what is wrong with my code :(

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 yesterdays 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

Date yesterday = new Date(System.currentTimeMillis()  oneDay);

it says Multiple markers at this line
- Syntax error on token "Invalid Character", ,
expected

2. Senior Member
Join Date
Aug 2009
Posts
2,388
Rep Power
7
Format your code with proper indentation and use code tags when posting the code.

3. First rule: Always put your code in CODE tag and it should be properly formatted

For now change the below line in your code at line 52

Java Code:
```long newDate = System.currentTimeMillis() - oneDay;
Date yesterday = new Date(newDate);```

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•