Hello, I really could use help on an assignment to code a health record program to collect info on a patient that inputs data about themselves (name, birthday, height, weight etc.) then calculates their BMI and displays all the values in the main method. The programming requires it be be in two classes with input data as private variables using constructors to pass the info around and a main method to display all the values. Anything can be put in for String variables like their name, but for a number variable like age must be within a set range, and if the answer isn't in that range, the user will be prompted on loop until it is. Two methods are public, one to read values and the other to display them, and the setter and getter methods and the BMI calculation methods are private.
I only have this so far:
package lab01; import java.util.Scanner; import java.lang.Long; class HealthRecord { private String firstName; private String lastName; private String email; private int age; private long ssn; private double phoneNumber; private double weight; private double height; long phoneNum = 9999999999L; long socialS = 9999999999L; Scanner scan = new Scanner(System.in); public HealthRecord(String firstName2, String lastName2, String email2, int age2, long ssn2, double phoneNumber2, double weight2 , double height2) { firstName = firstName2; lastName = lastName2; email = email2; age = age2; ssn = ssn2; phoneNumber = phoneNumber2; weight = weight2; height = height2; } private void setfirstName (String firstName2) { System.out.println("Please enter your first name: "); firstName = scan.nextLine(); firstName = firstName2; } private void setlastName (String lastName2) { System.out.println("Please enter your last name: "); lastName = scan.nextLine(); lastName = lastName2; } private void setEmail (String email2) { System.out.println("Please enter your email: "); email = scan.nextLine(); email = email2; } private void setAge(int age2) { System.out.println("Please enter your age from 1 to 125, (Ex. : 18) : "); age = scan.nextInt(); while (age < 1 || age > 125) { System.out.println("Invalid input, please try again: "); } age = age2; } private void setphoneNumber(long phoneNumber2) { System.out.println("Please enter your phone number (Ex. 6103258056) "); phoneNumber = scan.nextInt(); while (phoneNumber < 1 || phoneNumber > phoneNum) { System.out.println("Invalid input, please try again: "); } phoneNumber = phoneNumber2; } private void setWeight (double weight2) { System.out.println("Please enter your weight in pounds from 1 to 1400 (Ex 250) : "); weight = scan.nextDouble(); while (weight < 1 || weight > 1400) { System.out.println("Invalid input, please try again: "); } weight = weight2; } private void setHeight (double height2) { System.out.println("Please enter your height in inches from 1 to 108 (Ex. 72): "); height = scan.nextDouble(); while (height < 1 || height > 108) { System.out.println("Invalid input, please try again: "); } height = height2; } private void setSSN (long ssn2) { System.out.println("Please enter your SSN (Ex. 1867459824): "); ssn = scan.nextInt(); while (ssn < 1 || ssn > socialS) { System.out.println("Invalid input, please try again: "); } ssn = ssn2; } public void readInputs () { } class HealthRecordDemo { } }
It's been hard to work with encapsulation, and trying to work at it for some time, only a small part off it is that I only think will work. And since the instructor requires students to only use Netbeans though we've only been working with BlueJay up until now, it makes coding even more complicated. So help would be very much appreciated here.