Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: Health Records Profile Program

  1. #1
    Junior Member
    Join Date
    Sep 2019
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Exclamation Health Records Profile Program

    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.

  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,140
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: Health Records Profile Program

    Also posted at: https://www.dreamincode.net/forums/t...encapsulation/
    And here: https://coderanch.com/t/716026/java/...rofile-Program

    http://www.javaprogrammingforums.com...s-posting.html
    If you don't understand my answer, don't ignore it, ask a question.

Similar Threads

  1. Replies: 2
    Last Post: July 15th, 2011, 02:39 AM
  2. Program to read & write the Employee Records
    By arvindk.vij in forum Member Introductions
    Replies: 1
    Last Post: February 11th, 2011, 01:19 AM
  3. Program to read & write the Employee Records
    By arvindk.vij in forum Java Theory & Questions
    Replies: 1
    Last Post: February 11th, 2011, 01:19 AM
  4. Java/J2EE Developer - International Public Health/NGO
    By glugueMSH in forum Paid Java Projects
    Replies: 0
    Last Post: December 13th, 2010, 12:58 PM

Tags for this Thread