Question

In: Computer Science

You are working as a software developer for a large insurance company. Your company is planning...

You are working as a software developer for a large insurance company. Your company is planning to migrate the existing systems from Visual Basic to Java and this will require new calculations. You will be creating a program that calculates the insurance payment category based on the BMI score.

Your Java program should perform the following things:

  1. Take the input from the user about the patient name, weight, birthdate, and height.
  2. Calculate Body Mass Index.
  3. Display person name and BMI Category.
    1. If the BMI Score is less than 18.5, then underweight.
    2. If the BMI Score is between 18.5-24.9, then Normal.
    3. If the BMI score is between 25 to 29.9, then Overweight.
    4. If the BMI score is greater than 29.9, then Obesity.
  4. Calculate Insurance Payment Category based on BMI Category.
    1. If underweight, then insurance payment category is low.
    2. If Normal weight, then insurance payment category is low.
    3. If Overweight, then insurance payment category is high.
    4. If Obesity, then insurance payment category is highest.
  5. Implement exception handling.
  6. Store all the information in the file. You need to use the loop and keep asking users to enter patient name, height, weight, and birthdate. Your program should calculate BMI Category and Insurance payment category and write it to the file. Your program should stop once user enter q character.
  7. Create an interface called as the patient and then implement the interface as well as all the above methods.

You need to submit the following things:

  • An entire Java solution
  • Attach the output screenshot created using Microsoft Word

Solutions

Expert Solution

Thanks for the question.

Here is the completed code for this problem. Comments are included so that you understand whats going on. Let me know if you have any doubts or if you need anything to change.

Thank You !!

================================================================================================
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Scanner;

public class Patient {

    private String patientName;
    private String dob;
    private double weight;
    private double height;


    // constructor takes all the details - name, dob, height and weight
    public Patient(String patientName, String dob, double weight, double height) {
        this.patientName = patientName;
        this.dob = dob;
        if (weight < 0 || height < 0)
            throw new IllegalArgumentException("Invalid Weight/Height entered");
        this.weight = weight;
        this.height = height;
    }

    public String getPatientName() {
        return patientName;
    }

    public String getDob() {
        return dob;
    }

    public double getWeight() {
        return weight;
    }

    public double getHeight() {
        return height;
    }

    // calculate the BMI and returns the value
    public double calculateBMI() {

        return weight / (height * height);
    }


    public static void main(String[] args) {

        ArrayList<Patient> patients = new ArrayList<Patient>();
        Scanner scanner = new Scanner(System.in);

        // loop until user presses Q
        while (true) {
            System.out.print("Enter patient name: ");
            String patientName = scanner.nextLine();
            System.out.print("Enter birthdate(mm/dd/yyyy): ");
            String dob = scanner.nextLine();
            System.out.print("Enter weight (kg): ");
            double wt = scanner.nextDouble();
            System.out.print("Enter height (meters): ");
            double height = scanner.nextDouble();
            try {
                Patient aPatient = new Patient(patientName, dob, wt, height);
                patients.add(aPatient);
            } catch (IllegalArgumentException exception) {
                System.out.println(exception.getMessage());
            }
            scanner.nextLine();
            System.out.print("Do you want to quit(press q/Q):");
            String quit = scanner.nextLine();
            if (quit.equalsIgnoreCase("q")) break;
        }
        try {
            saveToFile(patients);
            System.out.println("Data saved in file successfully.");
        } catch (IOException e) {
            System.out.println("Unable to write datat to file.");
        }

    }

    // takes in the list of patient objects and write them to file

    private static void saveToFile(ArrayList<Patient> patients) throws IOException {

        PrintWriter writer = new PrintWriter(new FileWriter("F:\\patients.txt"));
        for (Patient patient : patients) {
            double bmi = patient.calculateBMI();

            StringBuilder builder = new StringBuilder();
            builder.append(patient.getPatientName()).append(",");
            builder.append(patient.getDob()).append(",");
            builder.append(patient.getHeight()).append(" meters,");
            builder.append(patient.getWeight()).append(" kg(s), ");
            if (bmi <= 18.5) builder.append("Insurance Category: Low");
            else if (bmi <= 24.9) builder.append("Insurance Category: Low");
            else if (bmi <= 29.9) builder.append("Insurance Category: High");
            else builder.append("Insurance Category: Highest");
            builder.append("\r\n");
            writer.write(builder.toString());
            writer.flush();

        }
        writer.close();

    }


}


Related Solutions

You are working as a software developer for a large insurancecompany. Your company is planning...
You are working as a software developer for a large insurance company. Your company is planning to migrate the existing systems from Visual Basic to Java and this will require new calculations. You will be creating a program that calculates the insurance payment category based on the BMI score.Your Java program should perform the following things:Take the input from the user about the patient name, weight, birthdate, and height.Calculate Body Mass Index.Display person name and BMI Category.If the BMI Score...
Suppose your first job after graduating from college is working at a large insurance company. Your...
Suppose your first job after graduating from college is working at a large insurance company. Your boss asks you to analyze the impact self-driving cars will have on revenues from car insurance policies. List four ways self-driving cars could impact the insurance industry. Justify your answers.
Create a company that should be related to your major(SOFTWARE DEVELOPER) in some way or directly...
Create a company that should be related to your major(SOFTWARE DEVELOPER) in some way or directly related to your plans for the future. Once you know what that company will be and have laid out some ideas about what you will need in terms of office For this discussion board post, you need to choose three countries on three different continents and research some basic information about them with regard to starting or developing a business there. What are the...
Company is Apple Apple (who you are - Software developer) (Team you manage – App management...
Company is Apple Apple (who you are - Software developer) (Team you manage – App management ). What type of training do your employee needs? Why do they need training? Need Analysis info Determine an instructional scenario where new or revised training is appropriate; where there is an obvious gap between knowledge and performance. Determine what techniques you will use to gather data to substantiate the instructional need (surveys,questionnaires, interviews, etc). Develop a needs assessment instrument. Survey your target population/gather...
Comapny is APPLE, Inc Summarize the company. - Apple (who you are - Software developer) (Team...
Comapny is APPLE, Inc Summarize the company. - Apple (who you are - Software developer) (Team you manage – App management ). What type of training do your employee needs? Why do they need training? Need Analysis info Determine an instructional scenario where new or revised training is appropriate; where there is an obvious gap between knowledge and performance. Determine what techniques you will use to gather data to substantiate the instructional need (surveys,questionnaires, interviews, etc). Develop a needs assessment...
Choice 1. You are the new software developer at work. You are brought into a meeting...
Choice 1. You are the new software developer at work. You are brought into a meeting with clients that do not understand the idea of sorting data. Now you know, that you cannot use complex math to explain, but you can illustrate in diagrams. Basically, this group has been working with unsorted data and you must explain why their searches and reports will be so much faster with sorted data. You do not know anything specific about their data, but...
Assume that you are working for a company that develops software systems for in-house use in...
Assume that you are working for a company that develops software systems for in-house use in its design of aircraft engines. Being a software engineer you may not have any expertise in aircraft engines. While testing programs for such applications, what are the challenges you are likely to face, and how will you overcome them?
You are working for a company that is planning to invest in a foreign country. Management...
You are working for a company that is planning to invest in a foreign country. Management has requested a report regarding the attractiveness of alternative countries based on the potential return of foreign direct investment (FDI). A colleague mentioned a potentially useful tool called the FDI Confidence Index, which is updated periodically. Find this index online and analyze how the index is constructed. Discuss the countries that are ranked in the top 20 based on the FDI Confidence Index using...
You are a renowned software developer and you have been hired by an old British boyband...
You are a renowned software developer and you have been hired by an old British boyband that wants to make a comeback in the industry. They ask you to make an app to showcase their new music and events. In your implementation, you have a class for each of the 5 group members, but you find that compiling each band member’s class takes more time than you currently have. Luckily, you remember that you learned about Makefiles in your favorite...
RUN THIS PROGRAM ON NETBEANS As a Software Developer, you have received a requirement from a...
RUN THIS PROGRAM ON NETBEANS As a Software Developer, you have received a requirement from a Company to implement a prototype for its payroll system. You receive the following specifications: If an employee works more than its regular hours, it is considered overtime and it will be paid based on the employee’s experience. All employees are paid biweekly (80 hours) Employee taxes: 1% This company manages three categories of workers based on employee’s experience. Group 1 (Silver) o Pay rate:...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT