i'm not sure why it wont return the value for this else if? It should return €175.0 but it always returns €100.0
Also, could this code be more efficient somehow?
thanks and any help is appreciated.
double fineCost = 0; //fine
double d = a[0]; //speed
double InitialFine = 75.00;
double Deduction = 50.00;
double total = 0;
a[0] = Console.readInt("Please enter student classification 1-4:");
{
if (d > 35 && d <= 40)
fineCost = InitialFine;
else if(d >= 41 && d<= 45)
{
fineCost = 25.50;
total = fineCost + InitialFine;
}
else if (d >= 46 && d <= 50)
{
fineCost = 51.0;
total = fineCost + InitialFine;
}
else if (d >= 51 && d <= 55)
{
fineCost = 76.50;
total = fineCost + InitialFine;
}
else if (d >= 56)
{
fineCost = 100.00;
total = fineCost + InitialFine;
}
else if (d < 55)
{
fineCost = total - Deduction;
}
}
System.out.println("The speeding fine is: €"+fineCost );
return total;
}

New Topic/Question
Reply



MultiQuote



|