I am new to coding and was wondering how would I go about coding this fine? I am pretty sure I am going about it the wrong coding way if anyone could help that would be greatly appreciated.
Below is what is expected:
The fine will be a dollar value, which is a double data type. ParkingTicket will not have a double-typed fine variable. Instead, it calculates the fine on-demand, using the minutesPaid and minutesParked variables. Impark levies a flat-rate fine of $20 (always), plus $10 aggravated penalties for every whole hour (60 minutes) parked beyond the paid amount. As a Canadian institution, Impark is also obligated to add the 5% Goods and Services Tax surcharge. A surcharge is multiplied after all other sums have been calculated. You are responsible for producing the result of this calculation in calculateFine().
So far this is what I have, :
public static double calculateFine()
{
double meterMinutesPaidWithTax = 20*0.05;
double meterMinutesPaid = 20;
double pentalty = 10;
double tax = 0.05;
double overParked = (carMinutesParked+=1);
if(carMinutesParked<=carMinutesParked){
return meterMinutesPaidWithTax = meterMinutesPaidWithTax+meterMinutesPaid;
}
else if(carMinutesParked>overParked){
return meterMinutesPaid = (meterMinutesPaid + pentalty)*tax+(meterMinutesPaid + pentalty);
}
else{
return meterMinutesPaidWithTax;
}
}