I have problem compile this. Line 23 having a problem ( possible loss precision, required int, found double).
public void actionPerformed( ActionEvent e )
{
try
{
// call a function to get the value - if an error occurs,
// display a message box and set focus to the correct field
double Limit = checkField( speedLimit, "" );
double Travel = checkField( speedTravel, "" );
double Previous = checkField( tickets, "" );
double Over = Travel - Limit;
double Cost = Over*20;
DecimalFormat df = new DecimalFormat( "#,###,##0.00" );
speedOver.setText( "" +
df.format( Over ) );
speedOver.setBackground( Color.YELLOW );
speedCost.setText( "" +
df.format( Cost ) );
speedCost.setBackground( Color.PINK );
switch(Previous)
{
case 0:
courtCost.setText( "" +
df.format( 74.80 ) );
courtCost.setBackground( Color.GRAY );
break;
case 1:
courtCost.setText( "" +
df.format( 74.80 + 25 ) );
courtCost.setBackground( Color.GRAY );
break;
case 2:
courtCost.setText( "" +
df.format( 74.80 + 50 ) );
courtCost.setBackground( Color.GRAY );
break;
}
outputLabel.setText( "The average annual cost to operate this appliance is $" +
df.format( Cost ) );
outputLabel.setBackground( Color.YELLOW );
}
}