// Practical 7A (Revision) - Q6
// Marcus Ward
// 26/10/2011
/* User will enter details, and program will calculate + display
insurance premium. */
import java.util.Scanner;
public class DriverPremium
{
public static void main(String[] args)
{
Scanner keyboardIn = new Scanner(System.in);
// declare variables
double premium, age, carValue, penaltyPoints, drivingExperience;
String gender;
// get user input
System.out.print("Please enter your age: ");
age = keyboardIn.nextInt();
System.out.print("Please enter your gender: ");
gender = keyboardIn.nextLine();
System.out.print("Please enter the value of your car: ");
carValue = keyboardIn.nextInt();
System.out.print("Please enter number of points on your license: ");
penaltyPoints = keyboardIn.nextInt();
System.out.print("Please enter number of years that you are driving: ");
drivingExperience = keyboardIn.nextInt();
premium = carValue*.05;
if (age<28)
premium = (carValue*0.5) + 175;
else if (gender == female)
premium = (carValue*0.5) * 0.8;
else if (drivingExperience>=20&&penaltyPoints==0)
premium = (carValue*0.5) * 0.8;
else if ((drivingExperience>=8&&drivingExperience<20)&&pen altyPoints==0)
premium = (carValue*0.5) * 0.8;
else if (penaltyPoints>8)
System.out.println("We unfortunately cannot insure you");
}
}
Error Message
DriverPremium.java:36: cannot find symbol
symbol : variable female
location: class DriverPremium
else if (gender == female)