Lab 1

Create a new Console Application using Visual Studio. Use the application to complete the following activities:

  • Define a class that represents a person. Define properties in the class for the person's complete name (text) and age (numeric)
  • In the program's "Main" routine, define a new instance of the class and populate its name and age properties
  • Accept user input to update the class object's properties with new values from the command line

Lab 2

Add on to Lab 1. For Lab 2, lets add methods to the person class to learn more about overloading methods. We need to add methods to set a person's address and set their height and weight several different ways using method overloading, as discussed below.

Lab Requirements:

Make a copy of your Lab1 to add functionality to

  • Add private instance variables to the Person class to store and address
    • street, city, state, and zip
    • All as Strings
  • Create the following three setAddress() methods.
    • public void setAddress(String street, String city, String state, String zip)
    • public void setAddress(String city, String state, String zip)
    • public void setAddress(String state, String zip)
    • Allow a client to supply a null or empty street and city values. If the values are null or empty strings, set the value to "Unknown".
    • If the client uses a null or empty state or zip, the program should tell the user that the values must be used and then exit.
    • Keep in mind you can call existing methods to simplify your logic and make the code easier to maintain
  • Create a method, outputAddress(), that outputs the persons address as shown below
Street: 3219 Lenard St
City: Yosomite
State: NY
Zip: 38203
  • Add private instance variables to store a person's height and weight
    • Both height and weight should be of type double
    • Height will be in inches and weight will be in pounds
  • Create the following setHeight() and setWeight() methods.
    • public void setHeight(double inches)
    • public void setHeight(int inches)
    • public void setHeight(int feet, int inches)
    • public void setHeightCm(double centimeters)
    • public void setWeight(double pounds)
    • public void setWeight(int pounds)
    • public void setWeightKilo(double kilograms)
    • Keep in mind you can call existing methods to simplify your logic and make the code easier to maintain
  • Create a method, outputHeight(), that outputs the person's height in feet and inches as shown below Height 5' 7''
  • Create a method, outputWeight(), that outputs the person's weight to 2 decimal places in lbs as shown below
Height 5' 7''
  • places in lbs as shown below
Weight: 210.76 lbs
  • All code should be put in a package names code.class1.your_name
  • Create a driver method or class to test you program
Academic Honesty!
It is not our intention to break the school's academic policy. Posted solutions are meant to be used as a reference and should not be submitted as is. We are not held liable for any misuse of the solutions. Please see the frequently asked questions page for further questions and inquiries.
Kindly complete the form. Please provide a valid email address and we will get back to you within 24 hours. Payment is through PayPal, Buy me a Coffee or Cryptocurrency. We are a nonprofit organization however we need funds to keep this organization operating and to be able to complete our research and development projects.