Question
Asked by:
Elentius
Elentius
Rating : No Rating
Questions Asked: 11
Tutorials Posted: 0
 

$10.00 Java Program

Q:
Write a user-defined class called Person. This class should have private instance variables defined as:

private int age;
private String firstName;
private String lastName;
In addition, the class should have a constructor defined as:

public Person(String _firstName, String _lastName, int _age)
that assigns values to the private instance variables. The class should also include the following public methods:

public void printName() – prints the person's name
public void printAge() – prints the person's age
public void printAgeGroup() – prints the person’s age group (i.e. 20's. 30's, etc.)
Only include this last method if it is necessary to include logic in the assignment.

Write a second class with the method, public static void main(String args[]). At least two objects based on the Person class should be created in the method. The name, age, and age group should be displayed for each object.

 


   
   
   
   
 
Available Tutorials to this Question
Posted by:
Tigerr
Tigerr
Rating (27): A-
Questions Asked: 0
Tutorials Posted: 203, earned $267.79
 

$10.00 Perfect Person class with uses

  • This tutorial hasn't been purchased yet.
  • Posted on Jul 28, 2009 at 10:44:49PM
A:
Preview: ... private String lastName; <br> Person(String _firstName, String _lastName, int _age) {<br> this.firstName= _firstName;<br> this.lastName= _las ...

The full tutorial is about 274 words long .
Posted by:
CMBLUE
CMBLUE
Rating (17): A+
Questions Asked: 0
Tutorials Posted: 74, earned $284.70
 

$10.00 Program with comments

  • This tutorial was purchased 1 time and rated A+ by students like you.
  • Posted on Jul 28, 2009 at 10:45:10PM
A:
Preview: ... e in Person and TestPerson. You mi ...

The full tutorial is about 31 words long plus attachments.

Attachments:
Person.java (1K) (Preview)
TestPerson.java (0K) (Preview)
Posted by:
Komsomolets
Komsomolets
Rating (4): A+
Questions Asked: 0
Tutorials Posted: 22, earned $17.80
 

$6.00 Java Program

  • This tutorial hasn't been purchased yet.
  • Posted on Jul 29, 2009 at 09:19:23PM
A:
Preview: ... ram in ...

The full tutorial is about 7 words long plus attachments.

Attachments:
Person.java (0K) (Preview)
Main.java (0K) (Preview)
   
Join Now or Log In
Get Tutoring
Get Paid
Academic Honesty