Question 3 (Marks: 40)
The college that you attend requires an application that will print out a Course Report. You are
required to create an application that will allocate the following course data:
COURSE CODE COURSE NAME STUDENT NUMBERS LECTURER
DISD Diploma in Software Development 35 Mr Jones
DIWD Diploma in Web Development 28 Mrs Smith
DIDM Diploma in Data Metrics 39 Mr Ntsinga
Create a class named Course_Details that will contain get and set methods for the course name,
student numbers and lecturer. In the Course_Details class include a method called Assign Venue
that will randomly generate a Venue/Class for the course. Venues can be from 1 to 3 only. Your
main class must include a static method to handle the printing of the course report.
import java.util.Random;
public class CourseDetails {
private String courseName;
private int studentNumbers;
private String lecturer;
public String getCourseName() {
return courseName;
}
public void setCourseName(String courseName) {
this.courseName = courseName;
}
public int getStudentNumbers() {
return studentNumbers;
}
public void setStudentNumbers(int studentNumbers) {
this.studentNumbers = studentNumbers;
}
public String getLecturer() {
return lecturer;
}
public void setLecturer(String lecturer) {
this.lecturer = lecturer;
}
public int assignVenue() {
return new Random().nextInt(3) + 1;
}
}
public class Main {
public static void main(String[] args) {
CourseDetails courseDetails = new CourseDetails();
courseDetails.setCourseName("Diploma in Web Development");
courseDetails.setLecturer("Mrs Smith");
courseDetails.setStudentNumbers(28);
System.out.println("Course Report");
System.out.println("COURSE NAME: " + courseDetails.getCourseName());
System.out.println("STUDENT NUMBERS: " + courseDetails.getStudentNumbers());
System.out.println("LECTURER: " + courseDetails.getLecturer());
System.out.println("Venue/Class " + courseDetails.assignVenue());
}
}
Comments
Leave a comment