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: 3663266 • 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");
}
}

Honestly i dont know if any of this code will help build what is required, please let me know if it isnt. Thanks

Explanation / Answer

// Student.java

import java.util.Random;

class Student {
   String name;
   String behaviors[]=new String[]{"Reading","Surfing the web","Talking with other students"};
   public Student(String name) {
       this.name= name;
   }
  
   public String getBehavior(int randomNum)
   {
       return behaviors[randomNum];
   }
   public String whatsup() {
           Random randomGenerator = new Random();
           int randomNum = randomGenerator.nextInt(3);
       return getBehavior(randomNum);
   }
}

//Group.java

class Group {
   String name;
   Student[] students;
   public Group(String name) {
       this.name = name;
       students = new Student[4];
       students[0] = new Student("John");
       students[1] = new Student("Alica");
       students[2] = new Student("Bob");
       students[3] = new Student("Martin");
   }
   public void display() {
       System.out.println("Group name: "+name);
       System.out.print("Name of students in group: ");
       for(int i = 0; i < students.length; i++) {
           System.out.print(students[i]+" ");
       }
       System.out.println();
   }
  
   public static void main(String[] args) {
       Group group = new Group("Special");
       group.display();
   }
}

//App.java

public class App {
  
   public static void main(String[] args) {
       Group g = new Group("Changer");
       Student s[] = g.students;
       System.out.println(s[2].whatsup());
   }
}