Sure, I can help you with that. Here's the Java code for both parts:
Part 1 - The Student Class
java
public class Student {
private String lastName;
private String firstName;
private String id;
private int totalCredits;
private boolean activeStatus;
public Student(String lastName, String firstName, String id, int totalCredits, boolean activeStatus) {
this.lastName = lastName;
this.firstName = firstName;
this.id = id;
this.totalCredits = totalCredits;
this.activeStatus = activeStatus;
}
// Getters and Setters
public String getLastName() {
return lastName;
}
public void setLastName(String lastName) {
this.lastName = lastName;
}
public String getFirstName() {
return firstName;
}
public void setFirstName(String firstName) {
this.firstName = firstName;
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public int getTotalCredits() {
return totalCredits;
}
public void setTotalCredits(int totalCredits) {
this.totalCredits = totalCredits;
}
public boolean isActiveStatus() {
return activeStatus;
}
public void setActiveStatus(boolean activeStatus) {
this.activeStatus = activeStatus;
}
// Display Method
public void displayStudent() {
System.out.println("Student ID: " + id);
System.out.println("First Name: " + firstName);
System.out.println("Last Name: " + lastName);
System.out.println("Total Credits: " + totalCredits);
System.out.println("Active: " + activeStatus);
}
}
Part 2 - The StudentTest Class
java
import java.util.Scanner;
public class StudentTest {
public static void main(String[] args) {
// Create a new Student object
Student student = new Student("Jones", "Tamara", "12345", 34, true);
// Display the student information
student.displayStudent();
// Ask for an updated value for total credits
Scanner scanner = new Scanner(System.in);
System.out.print("Enter updated total credits: ");
int updatedCredits = scanner.nextInt();
// Update the student object with the new value
student.setTotalCredits(updatedCredits);
// Display the updated student information
student.displayStudent();
}
}
In this program, we create a Student object and display its information using the displayStudent() method. Then, we ask the user to enter an updated value for totalCredits, which we set using the setTotalCredits() method, and then display the updated information again using displayStudent().