Hi i have other problems in other class the questions is

The Person class
Create a class called "Person" that includes three pieces of information as instance variables: a name, address, and age. Your class should have a constructor that initializes the three instance variables. Provide a set and get method for each instance variable. If the age is not positive, set it to zero.
Write a test application named UsePerson that demonstrate the class you just created. Create two person objects and display each object's information. Then increment the age of the person by 5 years and display each person's info again.

What i did is all the things exept the increase 5 years i don't know how to do it if i put add it will increase it to much not 5 years

take a look to my cood

public class Person {
    private String name; 
    private String address;
    private double age; 

    public Person(){
        this.name = "";
        this.address = "";
        this.age = 0.0;
    }
    // non\default Constructor
    public Person (String name, String address, double age){
        this.name = name;
        this.address = address;
        this.age = age;
        if (age < 0)
            age = 0.0;
    } 

    public void setName (String name)
    {
        this.name = name; 

    } 
    public String getName (){

        return name;
    } 
    public void setAddress (String address){

        this.address = address;
    } 

    public String getAddress ()
    {
        return address;
    } 
    public void setage (double age){

        this.age = age;
    } 

    public double getage ()
    {
        return age;
    } 
    public void adjustAge(double increment){
        this.age = (this.age * increment) + this.age;
    }
    public String toString(){
        String output = "";
        output += "\nPersons Information: ";
        output += "\nPerson Name: " + this.name;
        output += "\nPerson Address: " + this.address;
        output += "\nPerson Age: " + this.age;

        return output;
    }

}

public class UsePerson {

    public static void main(String[] args) {
        Person sameer = new Person (" Sameer ", " 419 W.Linconln Rd ", 29);
        Person Kail = new Person (" Kail ", " 604 Wachinton St ", 26);
        System.out.println(sameer);
        System.out.println(Kail);
        System.out.println(" \nIncrease the Age for the first person ");
        sameer.adjustAge(+ 0.05);

        System.out.println(sameer);

        } 
    }

this.age = (this.age * increment) + this.age;

So if I am 40 and the increment is 5 I would be (40 * 5) + 40... talk about time flying. Why not just add increment to age?

Also, as a rule of convention: Person Kail = new Person the variable name Kail should be lowercase kail.

Yes Yes i did it
it is increasing 5 years you was right why i put timing and then plus but that way it increase and it worked and i fixed the vireable thank you for remind me ^^

thank you

this.age = (this.age + increment);
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.