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...
You are working as the software developer and need to identify the best sorting algorithm. You...
You are working as the software developer and need to identify the best sorting algorithm. You can pick any two-sorting algorithm. You need to determine which sorting algorithm is the best to sort the array of 10k elements. Use the following steps to help with your solution: Create C++ functions for any two-sorting algorithm. Write down the random array generation function to generate at least 10k elements. Pass the same array into both the sorting algorithm. Calculate the end transactiontime-start...
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.
You are working as an assistant in a design office. A developer in your local area...
You are working as an assistant in a design office. A developer in your local area has contacted your company looking for advice as to what would be a suitable project to meet the needs of the local community but also be a profitable investment. The developer is considering a number of different sites in the area. please research your local area(Hong Kong) and select an appropriate construction-based project. Topic:Minimising risk through design and specification P8 Utilise appropriate forms of...
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...
For this assignment, you will take on the role of software developer as part of a...
For this assignment, you will take on the role of software developer as part of a team of developers for a retail company. The payroll manager of the company has tasked you with developing a Java program (if you can put it in NetBeans that would be awesome) to quickly calculate an employee’s weekly gross and net pay. The program must prompt the user to enter the employee’s name, rate of pay, and hours worked. The output will display 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?
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT