In: Computer Science
Automobile Insurance Program:
Writes a program that prints the insurance fee to pay for a Vehicle according to the following rules:
A Honda that is All Wheel Drive costs $450.
A Honda that is two wheels drive costs $350.
A Toyota that is All Wheel Drive costs $300.
A Toyota that is Two Wheel Drive costs $250.
A Nissan that is All Wheel Drive costs $200.
A Nissan that is Two Wheel Drive costs $280.
import java.util.Scanner;
public class AutomobileInsurance {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
System.out.print("Enter make of the car(Honda, Toyota or Nissan): ");
String make = in.next();
System.out.print("1. All Wheel drive, 2. Two wheels. Enter your choice: ");
int tyreType = in.nextInt();
if (make.equalsIgnoreCase("Honda")) {
if (tyreType == 1) {
System.out.println("Insurance cost is $450");
} else {
System.out.println("Insurance cost is $350");
}
} else if (make.equalsIgnoreCase("Toyota")) {
if (tyreType == 1) {
System.out.println("Insurance cost is $300");
} else {
System.out.println("Insurance cost is $250");
}
} else if (make.equalsIgnoreCase("Nissan")) {
if (tyreType == 1) {
System.out.println("Insurance cost is $200");
} else {
System.out.println("Insurance cost is $280");
}
} else {
System.out.println("Invalid manufacturer type. Try again!");
}
in.close();
}
}