import java.io.*;
public class Assignment5
{
// declare global scope variables
private BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
private String inputString;
public Assignment5(){
//I-O-P
initialize();
insureProcess();
cleanUp();
}
public void initialize()
{
System.out.println();
System.out.println("Hello to the Good Hands Program. We would like to insure your car, but first we will need to go over a couple of things first.");
System.out.println();
}// end initialize
public void insureProcess() throws IOException
{
// declare local variable for car choice
String carChoice;
boolean insurable;
int year;
int carResult;
int yearResult;
System.out.print("Enter a car model: ");
carChoice = input.readLine();
// Check Model for insurability
carResults = checkModel(carChoice);
if (carResult==true)
{
System.out.print("Enter a year: ");
year = Integer.parseInt(input.readLine());
// Check Year for insurability
yearResults = checkYear(year);
}
// Print results based on insurability
if ((carResult==true) && (yearResult==true))
{
insurable = true;
} else
{
insurable = false;
}
printResults(insurable);
}// end insureProcess
public boolean checkModel(String carChoice)
{
if (carChoice.equalsIgnoreCase("Ford") || carChoice.equalsIgnoreCase("Chevy") || carChoice.equalsIgnoreCase("Toyota"))
{
return true;
}
return false;
}// end checkModel
public boolean checkYear(int year)
{ if (year > 1989)
{
return true;
}
return false;
}// end checkYear
public void printResults(boolean insurable)
{
if (insurable==true)
{
System.out.println("You are insurable!");
} else
{
System.out.println("Sorry we can not insure you at this time.");
}
}// end printResults
public void cleanup()
{
System.out.println("Normal termination have a nice day");
}// end cleanup
public static void main(String [] args) throws IOException // main method
{
new Assignment5();
} // end the main method
} // end the program