0% found this document useful (0 votes)
4 views4 pages

Vehicle Insurance Management System

The document outlines a Java program for a vehicle insurance management system, featuring classes for UnderWriter and VehicleInsurance, along with a main class StarProtectSystem for user interactions. It includes functionalities for admin and underwriter logins, registration of underwriters, and creation of vehicle insurance policies. The program utilizes a command-line interface for user input and manages data using lists for underwriters and insurance policies.

Uploaded by

rtandon3102
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views4 pages

Vehicle Insurance Management System

The document outlines a Java program for a vehicle insurance management system, featuring classes for UnderWriter and VehicleInsurance, along with a main class StarProtectSystem for user interactions. It includes functionalities for admin and underwriter logins, registration of underwriters, and creation of vehicle insurance policies. The program utilizes a command-line interface for user input and manages data using lists for underwriters and insurance policies.

Uploaded by

rtandon3102
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd

import [Link].

*;

class UnderWriter {
private static int counter = 1;
private int underwriterId;
private String name;
private Date dob;
private Date joiningDate;
private String password;

public UnderWriter(String name, Date dob, Date joiningDate, String password) {


[Link] = counter++;
[Link] = name;
[Link] = dob;
[Link] = joiningDate;
[Link] = password;
}

public int getUnderwriterId() { return underwriterId; }


public String getName() { return name; }
public String getPassword() { return password; }
public void setPassword(String password) { [Link] = password; }
}

class VehicleInsurance {
private static int policyCounter = 1000;
private int policyNo;
private String vehicleNo;
private String vehicleType;
private String customerName;
private int engineNo;
private int chasisNo;
private String phoneNo;
private String type;
private double premiumAmount;
private Date fromDate;
private Date toDate;
private int underwriterId;

public VehicleInsurance(String vehicleNo, String vehicleType, String


customerName, int engineNo, int chasisNo,
String phoneNo, String type, double premiumAmount, Date
fromDate, int underwriterId) {
[Link] = policyCounter++;
[Link] = vehicleNo;
[Link] = vehicleType;
[Link] = customerName;
[Link] = engineNo;
[Link] = chasisNo;
[Link] = phoneNo;
[Link] = type;
[Link] = premiumAmount;
[Link] = fromDate;
Calendar cal = [Link]();
[Link](fromDate);
[Link](Calendar.DAY_OF_YEAR, 365);
[Link] = [Link]();
[Link] = underwriterId;
}
}

public class StarProtectSystem {


private static List<UnderWriter> underwriters = new ArrayList<>();
private static List<VehicleInsurance> insurances = new ArrayList<>();
private static final String ADMIN_USER = "admin";
private static final String ADMIN_PASS = "admin@123";

public static void main(String[] args) {


Scanner scanner = new Scanner([Link]);
while (true) {
[Link]("1. Admin Login\n2. UnderWriter Login\n3. Exit");
int choice = [Link]();
switch (choice) {
case 1:
adminLogin(scanner);
break;
case 2:
underwriterLogin(scanner);
break;
case 3:
[Link](0);
default:
[Link]("Invalid option!");
}
}
}

private static void adminLogin(Scanner scanner) {


[Link]("Enter Admin Username: ");
String user = [Link]();
[Link]("Enter Password: ");
String pass = [Link]();
if ([Link](ADMIN_USER) && [Link](ADMIN_PASS)) {
adminMenu(scanner);
} else {
[Link]("Invalid Credentials!");
}
}

private static void adminMenu(Scanner scanner) {


while (true) {
[Link]("Admin Menu:\n1. Register UnderWriter\n2. View
Underwriters\n3. Logout");
int choice = [Link]();
switch (choice) {
case 1:
registerUnderwriter(scanner);
break;
case 2:
viewUnderwriters();
break;
case 3:
return;
default:
[Link]("Invalid Option!");
}
}
}
private static void registerUnderwriter(Scanner scanner) {
[Link]("Enter Name: ");
String name = [Link]();
[Link]("Enter DOB (yyyy-mm-dd): ");
String dobStr = [Link]();
[Link]("Enter Joining Date (yyyy-mm-dd): ");
String joiningDateStr = [Link]();
[Link]("Enter Password: ");
String password = [Link]();
[Link](new UnderWriter(name, new Date(), new Date(), password));
[Link]("Underwriter Registered Successfully!");
}

private static void viewUnderwriters() {


for (UnderWriter u : underwriters) {
[Link]("ID: " + [Link]() + ", Name: " +
[Link]());
}
}

private static void underwriterLogin(Scanner scanner) {


[Link]("Enter UnderWriter ID: ");
int id = [Link]();
[Link]("Enter Password: ");
String pass = [Link]();
for (UnderWriter u : underwriters) {
if ([Link]() == id && [Link]().equals(pass)) {
underwriterMenu(scanner, id);
return;
}
}
[Link]("Invalid Credentials!");
}

private static void underwriterMenu(Scanner scanner, int underwriterId) {


while (true) {
[Link]("UnderWriter Menu:\n1. Create Insurance\n2.
Logout");
int choice = [Link]();
switch (choice) {
case 1:
createVehicleInsurance(scanner, underwriterId);
break;
case 2:
return;
default:
[Link]("Invalid Option!");
}
}
}

private static void createVehicleInsurance(Scanner scanner, int underwriterId)


{
[Link]("Enter Vehicle No: ");
String vehicleNo = [Link]();
[Link]("Enter Vehicle Type: ");
String vehicleType = [Link]();
[Link]("Enter Customer Name: ");
String customerName = [Link]();
[Link]("Enter Engine No: ");
int engineNo = [Link]();
[Link]("Enter Chasis No: ");
int chasisNo = [Link]();
[Link]("Enter Phone No: ");
String phoneNo = [Link]();
[Link]("Enter Type (Full/ThirdParty): ");
String type = [Link]();
double premiumAmount = [Link]("Full") ? 10000 : 5000;
[Link](new VehicleInsurance(vehicleNo, vehicleType, customerName,
engineNo, chasisNo, phoneNo, type, premiumAmount, new Date(), underwriterId));
[Link]("Vehicle Insurance Created!");
}
}

Common questions

Powered by AI

New underwriters are registered through the "registerUnderwriter" method, which requires inputs for the underwriter's name, date of birth, joining date, and password. The details are encapsulated in a "UnderWriter" object and added to the "underwriters" list .

The validity duration of a vehicle insurance policy is set at creation by adding 365 days to the "fromDate" to compute the "toDate". A "Calendar" instance is used to achieve this: it sets the time to the "fromDate" and then increments the day of the year by 365 .

The system differentiates between admin and underwriter logins by prompting the user to choose from an initial menu. Admin login involves verification against fixed credentials and, upon success, accessing functionalities such as registering/viewing underwriters. Underwriter login requires matching an ID and password, focusing on creating vehicle insurances .

The system manages and stores information about created vehicle insurance policies by creating "VehicleInsurance" objects with detailed attributes such as vehicle and customer information. These objects are added to the "insurances" list, serving as the storage mechanism .

The "adminLogin" method fulfills the role of authenticating an administrator by prompting for a username and password. It checks these credentials against predefined constants ("ADMIN_USER" and "ADMIN_PASS"). If they match, it grants access to the admin menu; otherwise, it outputs an "Invalid Credentials!" message .

Static variables for ID counters ensure that each instance of either "UnderWriter" or "VehicleInsurance" possesses a unique, sequential identifier independent of objects' lifespan, sharing this state across all class instances. This approach efficiently tracks globally unique identifiers without external management .

The premium amount in the vehicle insurance creation process is determined based on the type of insurance coverage chosen. If the insurance type is "Full," the premium amount is set to 10,000; if "ThirdParty," the premium is 5,000 .

The unique identification for underwriters in the software system is generated and managed using a static variable "counter" that starts at 1. Each time a new "UnderWriter" object is created, this counter increments by 1 to ensure each underwriter has a unique "underwriterId" .

Data encapsulation in the "UnderWriter" class is ensured by declaring the instance variables: "underwriterId," "name," "dob," "joiningDate," and "password" as private. Access to these variables is controlled through public methods such as getUnderwriterId(), getName(), and getPassword().

The credential checking mechanism in "underwriterLogin" is effective in that it compares the provided ID and password with stored "UnderWriter" objects, ensuring only valid credentials grant access. However, storing plain passwords highlights a lack of advanced security practices such as hashing .

You might also like