Answer to Question #203864 in Java | JSP | JSF for emily

Question #203864

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.




1
Expert's answer
2021-06-06T08:56:39-0400
import java.util.Random;
public class Course_Details{
    private String course_name,lecturer;
    private int student_no;
    public void setCourseName(String n){
        course_name=n;
    }
    public String getCourseName(){
        return course_name;
    }
    public void setStudentNo(int s_no){
        student_no=s_no;
    }
    public int getStudentNo(){
        return student_no;
    }
    public void setLecturer(String l){
        lecturer=l;
    }
    public String getLecturer(){
        return lecturer;
    }
    public int assignValue(){
        Random rand = new Random();
        int value =1+(rand.nextInt(3));
        return value;
    }
    public static void display(){
        Course_Details c1 = new Course_Details();
        c1.setCourseName("Computer Science");
        c1.setStudentNo(50);
        c1.setLecturer("John");
        System.out.println("Course name: "+c1.getCourseName());
        System.out.println("Number of Students: "+c1.getStudentNo());
        System.out.println("Lecturer: "+c1.getLecturer());
        System.out.println("Venue: "+c1.assignValue());
    }
    public static void main(String[] args) {
        Course_Details c1 = new Course_Details();
        c1.display();
        
    }
}

Output






Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS