我一直在试图弄清楚为什么这个基本的 java 程序不会运行。我得到大约 7 个找不到符号错误。任何帮助将非常感激。我很想知道我做错了什么。
该程序只是一些基本的计算,提示输入和输出数据,显示超速者的罚款是多少。
import java.io.*;
import java.util.*;
public class Lab1 {
public static void main (String args[]) {
// Create a scanner to read from keyboard
Scanner kbd = new Scanner(System.in);
System.out.print("\nEnter Driver's FIRST Name.");
String firstName = kbd.next();
System.out.print("\nEnter Driver's LAST Name.");
String lastName = kbd.next();
System.out.print("\nEnter Driver's Age.");
int age = Integer.parseInt(kbd.next());
System.out.print("\nEnter the Speed Limit.");
int speedLimit = Integer.parseInt(kbd.next());
System.out.print("\nEnter Driver's Actual Speed");
int actualSpeed = Integer.parseInt(kbd.next());
System.out.print("\nDid violation occur in construction zone? (yes/no)");
String constructionZone = kbd.next();
int speedDifference = (actualSpeed - speedLimit);
if (speedDifference <= 5) {
int baseFine = 0;
}
else if(speedDifference >= 20) {
int baseFine = (speedDifference / 5) * 50;
}
else {
int baseFine = (speedDifference / 5) * 30;
}
if(constructionZone.equals("yes")) {
int constructionFine = 10;
}
else {
int constructionFine = 0;
}
if(age <= 21 && speedDifference >= 20) {
int underageFine = 300;
}
else {
int underageFine = 0;
}
int totalFine = baseFine + constructionFine + underageFine;
System.out.println("Last Name: " + lastName);
System.out.println("First Name: " + firstName);
System.out.println("Driver Age: " + age);
System.out.println("Speed Limit: " + speedLimit);
System.out.println("Actual Speed: " + actualSpeed);
System.out.println("MPH Over Limit: " + speedDifference);
System.out.println("Base Fine: $" + baseFine);
System.out.println("Construction Zone Fine: $" + constructionFine);
System.out.println("Underage Fine: $" + underageFine);
System.out.println("Total Fine: $" + totalFine);
}
}