Created
February 28, 2023 09:06
-
-
Save SamarthBhogre/5b59b582bc0ed3aec3b9b66cadb23c64 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Person { | |
private int person_id; | |
private String name; | |
private int age; | |
public Person(int person_id, String name, int age){ | |
this.person_id = person_id; | |
this.name = name; | |
this.age = age; | |
} | |
public int getPerson_id(){ | |
return person_id; | |
} | |
public String getName(){ | |
return name; | |
} | |
public int getAge(){ | |
return age; | |
} | |
public void ageGroup(){ | |
if (age < 8) { | |
System.out.println("Child"); | |
} else if (age > 8 && age < 20) { | |
System.out.println("Teenage"); | |
} else if (age >= 20 && age <= 40) { | |
System.out.println("Young"); | |
} else { | |
System.out.println("Old"); | |
} | |
} | |
} | |
public class pr8b { | |
public static void main(String []args){ | |
Person p1 = new Person(1, "Samarth", 18); | |
p1.ageGroup(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment