In this activity, you will write your own Java program that uses abstract classes to send out different announcements to graduate students at your college that are in different years of study.

Announcement

Instructions:
Using any application of your choice, write a Java program that meets the following requirements:
It has an abstract class that contains a student number;
Include get() and set() methods for the abstract class where the student number is set/get;
Create three child classes, for firstYear, secondYear and thirdYear.
Each class must display a distinct announcement for first years, second years and third years.
Save your program.
Compile and run your program and save a screenshot of the output, using your student number in the file name.
Copy the program code.
Return to this screen and click the link above the red arrow to open the Discussion tool.
In a new thread, enter “Announcements” in the Subject field and paste the code that you copied in Step 4 above.
View the code posted by other students in the group and reply to the entry of at least one of them, stating what you think the output of the code will be.
View the response to your entry and state whether the output they provided was correct. Attach your screenshot from Step 3 in support.

import java.util.Scanner;

abstract class Student {
protected String studentNumber;

public void setStudentNumber(String studentNumber) {
this.studentNumber = studentNumber;
}

public String getStudentNumber() {
return studentNumber;
}

public abstract void displayAnnouncement();
}

class FirstYear extends Student {
public void displayAnnouncement() {
System.out.println("Welcome to your first year of study!");
}
}

class SecondYear extends Student {
public void displayAnnouncement() {
System.out.println("Congratulations on entering your second year!");
}
}

class ThirdYear extends Student {
public void displayAnnouncement() {
System.out.println("You're almost there! Welcome to your third year!");
}
}

public class Announcements {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);

System.out.print("Enter your student number: ");
String studentNumber = scanner.nextLine();

FirstYear firstYear = new FirstYear();
firstYear.setStudentNumber(studentNumber);

SecondYear secondYear = new SecondYear();
secondYear.setStudentNumber(studentNumber);

ThirdYear thirdYear = new ThirdYear();
thirdYear.setStudentNumber(studentNumber);

firstYear.displayAnnouncement();
secondYear.displayAnnouncement();
thirdYear.displayAnnouncement();
}
}

// Output:
// Enter your student number: 1234567
// Welcome to your first year of study!
// Congratulations on entering your second year!
// You're almost there! Welcome to your third year!