Question
person.java public class Person { String name; int age; Person(String nam,int a) { name=nam; age=a; } public int getAge() { return age; } } student.java
person.java
public class Person {
String name;
int age;
Person(String nam,int a)
{
name=nam;
age=a;
}
public int getAge()
{
return age;
}
}
student.java
public class Student extends Person{
String course;
public Student()
{
super("", 0);
course="";
}
public Student(String nam, int a,String c) {
super(nam, a);
course=c;
}
public String getCourse()
{
return course;
}
public String getName()
{
return this.name;
}
}
group.java
import java.util.Scanner;
public class group {
String groupName;
Student students[];
public group(String gname)
{
groupName=gname;
students=new Student[4];
}
public void setStudents()
{
Scanner scan=new Scanner(System.in);
for(int i=0;i
{
System.out.println("Enter the details for student "+(i+1));
System.out.println("Enter Name:");
String name=scan.nextLine();
System.out.println("Enter Age:");
int age=scan.nextInt();
scan.nextLine();
System.out.println("Enter Course:");
String course=scan.nextLine();
students[i]=new Student(name,age,course);
}
}
public void display()
{
System.out.println("Group Details:");
System.out.println("Group Name: "+groupName);
System.out.println("Name of the students in the group:");
for(int i=0;i
{
students[i].getName();
}
}
}
app.java
public class App {
group g;
App(String gname)
{
g=new group(gname);
}
public void createGroup()
{
g.setStudents();
}
public void whatsUp()
{
System.out.println("Details of the third student in the group");
System.out.println(g.students[2].getName()+" is doing" +g.students[2].getCourse());
}
public void displayGroup()
{
g.display();
}
}
whatsapp.java
import java.util.Scanner;
public class Whatsapp {
public static void main(String[] args) {
Scanner scan=new Scanner(System.in);
System.out.println("Enter Group Name:");
String gname=scan.nextLine();
App whatsApp=new App(gname);
whatsApp.createGroup();
whatsApp.displayGroup();
whatsApp.whatsUp();
}
}
If you can complete the required tasks for the assignment without my code that will work. Thanks
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started