Assume that you are working for hypothetical insurance company. This company off
ID: 3551344 • Letter: A
Question
Assume that you are working for hypothetical insurance company. This company offers insurance for 4 types of vehicles: cars, trucks, motor cycles and boats. In order to keep the program manageable, we will assume that we do not make a finer distinction among various types that can be found among each type of vehicle. For example, we do not care if it is a small car, or a big car. Your program is required to calculate the applicable insurance premium for a potential customer given the number of vehicles insured. This customer may want insurances for one or more vehicle; you do not know ahead of time the number of vehicles. Since you have no means of storing the result, you will be printing out the insurance value for each vehicle before proceeding with the calculation for the next vehicle. Once all vehicle insurances are calculated and printed, you will print a summary showing the number of vehicles insured for that person and the total premium due from the customer. You are free to choose other output lines to make the output user friendly.
1. The base premiums are:
Passenger car: $297
Light Truck: $350
Motor Cycle: $500
Boat: $297
These could be treated as Constants for this program.
2. Multi-vehicle discount: This depends on the accident history.
Accident history:
Explanation / Answer
package useInsurnace; import java.util.*; public class UseInsurance { public static void main(String [] str) throws Exception { Insurance item; char inputChar;Scanner keyboard = new Scanner(System.in);
System.out.println("What type of insurance do you wish?"); System.out.println("Enter 1 for Health "); System.out.println(" 2 for Life "); System.out.println(" 3 for Auto "); inputChar = keyboard.next().charAt(0);
if(inputChar == '1') item = new HealthInsurance(3233,200,2400);
else if(inputChar == '2') item = new LifeInsurance(1234,100,1200);
else if(inputChar == '3') item = new AutoInsurance(3333, 50, 600, "987654321A2008B"); else { System.out.println("Invalid Insurance Choice"); return; } item.print(); } } package useInsurnace; import java.util.*; public class UseInsurance { public static void main(String [] str) throws Exception { Insurance item; char inputChar;
Scanner keyboard = new Scanner(System.in);
System.out.println("What type of insurance do you wish?"); System.out.println("Enter 1 for Health "); System.out.println(" 2 for Life "); System.out.println(" 3 for Auto "); inputChar = keyboard.next().charAt(0);
if(inputChar == '1') item = new HealthInsurance(3233,200,2400);
else if(inputChar == '2') item = new LifeInsurance(1234,100,1200);
else if(inputChar == '3') item = new AutoInsurance(3333, 50, 600, "987654321A2008B"); else { System.out.println("Invalid Insurance Choice"); return; } item.print(); } }