Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

lab 1 code: import java.util.Scanner; public class app { private static class Pe

ID: 3663522 • Letter: L

Question

lab 1 code:

import java.util.Scanner;
public class app {

private static class Person {
   public static void main(String[] args){
       Scanner in = new Scanner(System.in);
       String person1, person2, person3;
       int age1, age2, age3;
       System.out.println("Enter Person 1 details");
       System.out.print("Name: ");
       person1 = in.nextLine();
       System.out.print("Age: ");
       age1 = in.nextInt();
       System.out.println("Enter Person 2 details");
       System.out.print("Name: ");
       in.nextLine();
       person2 = in.nextLine();
       System.out.print("Age: ");
       age2 = in.nextInt();
       System.out.println("Enter Person 3 details");
       System.out.print("Name: ");
       in.nextLine();
       person3 = in.nextLine();
       System.out.print("Age: ");
       age3 = in.nextInt();
       if(age1 < age2){
           if(age1 < age3){
               System.out.println(person1 + " is the youngest");
           }
           else{
               System.out.println(person3 + " is the youngest");
           }
           if(age2 > age3){
               System.out.println(person2 + " is the oldest");
           }
           else{
               System.out.println(person3 + " is the oldest");
           }
       }
       else{
           if(age2 < age3){
               System.out.println(person2 + " is the youngest");
           }
           else{
               System.out.println(person3 + " is the youngest");
           }
           if(age1 > age3){
               System.out.println(person1 + " is the oldest");
           }
           else{
               System.out.println(person3 + " is the oldest");
           }
       }
   }
}
  
}

lab 2 code:

import java.util.Random;

public class Student {
  
String behaviors[]=new String[]{"Reading","Surfing the web","Talking with other students"};
public String getBehavior(int randomNum)
{
return behaviors[randomNum];
}
public static void main(String[] args){

Student S=new Student();
System.out.println("Summary of Student behaviors in class");

for(int i=1;i<=20;i++)
{
Random randomGenerator = new Random();
int randomNum = randomGenerator.nextInt(3);
System.out.println("Minute "+i+" : "+S.getBehavior(randomNum));
}
}
}

Assign 1:

import java.util.ArrayList;

public class app {
public static void main(String args[]){

ArrayList<professor> professors = new ArrayList<professor>();

professor obj1 = new professor("virat","kohli",26,"Phd");
professor obj2 = new professor("MS","Dhoni",36,"BA");
professor obj3 = new professor("AB","Devillers",29,"Phd");

professors.add(obj1);
professors.add(obj2);
professors.add(obj3);

professors.get(0).printMinMax(professors);
}
}

import java.util.ArrayList;

public class professor {

String lastName;
String firstName;
int age;
String degree;

public professor(String lastName, String firstName, int age, String degree) {
this.lastName = lastName;
this.firstName = firstName;
this.age = age;
this.degree = degree;
}

Assign 2:

import java.util.Random;

public class Student{

String[] behaviors = {"Reading","Surfing the web","Talking with other students"};
public String getBehavior(int randomNum){
return behaviors[randomNum];
}
public static void main(String[] args){

Student S = new Student();
System.out.println("Summary of Student behaviors in class");
   
int[] interest = new int[3];
for(int i=1; i<=20; i++){
Random randomGenerator = new Random();
int randomNum = randomGenerator.nextInt(3);
System.out.println("Minute "+i+" : "+S.getBehavior(randomNum));
interest[randomNum] += 1;
}
for (int i = 0; i < 3; i++)
System.out.println(S.behaviors[i]+" "+(interest[]*100.0/20.0)+"% of the time");
}
}

If you can complete what is required for this assignment without my code i will be satisifed with that, what ever is easiest. Thanks

Deliverables group.java, app.java and student.java as requested below Create an application that . Creates 4 students o Build upon the solutions of the previous labs (e.g., using app.java and student.java) o You will need a version of student.java that has a working whatsup method Creates a group o First you have to design the new Java class called group A group has a name A group has 4 students Create a method in group.java that o displays the group name and the name of each student in the group in app.java us.ng the group variable (instance, object) in group.java o display information about what the third student in the group (retrieving information from the student class variables in the group, not from student variables in the app) is up to now (use the whatsUp() method). For instance: "John" is "doing Java" o Pay attention, you have to use a the group variable (instance, object) in app.java o Something like System.out.println( the student is+g1._

Explanation / Answer

//Programs:

/*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<4;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<4;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();

    }

}

/*================================================================*/

/*Driver class contains main(): 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();

    }

   

}