大家好,我是一名新的计算机科学专业学生,我正在尝试调用一种方法,但我不断收到此错误。这是我的问题区域:
calcTicket(String driverName, int speedDriving, int speedLimit, String schoolZone);
这是整个代码(不会太长):
import java.util.Scanner;
public class SpeedingTicket
{
public static void main(String[] args)
//Declarations and Instantiations
{
// Input Data
Scanner scan = new Scanner(System.in);
System.out.println("Enter driver's name: ");
String driverName = scan.nextLine();
System.out.println("Enter driver's speed: ");
int speedDriving = scan.nextInt();
System.out.println("Enter speed limit: ");
int speedLimit = scan.nextInt();
scan.nextLine();
System.out.println("Was driver in school zone? ");
String schoolZone = scan.nextLine();
}
// Call calcTicket
calcTicket(String driverName, int speedDriving, int speedLimit, String schoolZone);
/** Calculates the cost of a speeding ticket given the speed driven, limit, and if in a school zone.
*/
public static void calcTicket(String driverName, int speedDriving, int speedLimit, String schoolZone)
{
// Define constants here
final int INIT_ADDITIVE = 50;
final int NO_MULTIPLIER = 6;
final int YES_MULTIPLIER = 12;
final int MAX_ADDITIVE = 200;
final int EX_THRESH = 30;
// Calculations
int amountOver = (speedDriving - speedLimit);
if (schoolZone.equalsIgnoreCase("yes"))
{
if (amountOver > 0)
{ int fine = amountOver * YES_MULTIPLIER + INIT_ADDITIVE;
System.out.println(driverName +"owes: $" + fine);
}
if (amountOver > EX_THRESH)
{ int fine = amountOver * YES_MULTIPLIER + MAX_ADDITIVE;
System.out.println(driverName +"owes: $" + fine);
}
else
{ int fine = 0;
System.out.println(driverName +"owes: $" + fine);
}
}
if (schoolZone.equalsIgnoreCase("no"))
{
if (amountOver > 0)
{ int fine = amountOver * NO_MULTIPLIER + INIT_ADDITIVE;
System.out.println(driverName +"owes: $" + fine);
}
if (amountOver > EX_THRESH)
{ int fine = amountOver * NO_MULTIPLIER + MAX_ADDITIVE;
System.out.println(driverName +"owes: $" + fine);
}
else
{ int fine = 0;
System.out.println(driverName +"owes: $" + fine);
}
}
}
}