Question

In: Computer Science

Use JAVA to Design a simple registration system that allows Student to register in a course....

Use JAVA to Design a simple registration system that allows Student to register in a course.

Requirements

  • using 2 classes: class Student & class Course.
  • Implement the scenarios in class Test’s main method.
  • Each student has a name and an id variable.
  • Each object of class Student is initialized using values of name and id passed to constructor.
  • Class Student has get methods for its instance variables.(getters and setters)
  • Each Course has a name, and a variable numberOfStudent representing the number of registered students.
  • A course can have a maximum number of 10 students registered in it.
  • Class Course store the registered students in students which is an array of type Student. When a student register in a course, he is added to the array. Each object of class Course is initialized using the title(name).
  • Class Course has the following methods:
    • method getStudents(): return the array of registered students;
    • method boolean isFull(): return true if the course is full,
    • get method for the name and numberOfStudent field;
    • method registerStudent (Student student): if the course is not full, register a student in course.

Solutions

Expert Solution

The code is clearly explained in the comments of the code itself.

Code--

import java.util.*;
class Student
{
   //attributes
   private String name;
   private String id;
  
   //constructor with parameters
   public Student(String name, String id)
   {
       this.name = name;
       this.id = id;
   }
  
   //getters and setters
   public String getName()
   {
       return name;
   }
   public void setName(String name)
   {
       this.name = name;
   }
   public String getId()
   {
       return id;
   }
   public void setId(String id)
   {
       this.id = id;
   }
  
}
class Course
{
   //attributes
   private String name;
   private int numberOfStudent;
   Student[] students= new Student[10];
   //each object of the class is initialized using the title name
   public Course(String name)
   {
       this.name=name;
       this.numberOfStudent=0;
   }
   public Student[] getStudents()
   {
       return students;
   }
   public boolean isFull()
   {
       if(this.numberOfStudent==10)
       {
           return true;
       }
       else
       {
           return false;
       }
   }
   //get methods
   public String getName()
   {
       return name;
   }
   public int getNumberOfStudent()
   {
       return numberOfStudent;
   }
   public void registerStudent(Student student)
   {
       if(!this.isFull())
       {
           numberOfStudent++;
           students[numberOfStudent-1]=new Student(student.getName(),student.getId());
       }          
   }
  
}

public class Tests
{
   public static void main(String[] args)
   {
       Student st=new Student("Tom","00");
       Course phy=new Course("Physics");
       phy.registerStudent(st);
       st=new Student("Sam","02");
       phy.registerStudent(st);
       st=new Student("Ram","03");
       phy.registerStudent(st);
       st=new Student("Shyam","04");
       phy.registerStudent(st);
      
       //display the students
       System.out.println("Course: "+ phy.getName());
       System.out.println("Number of students: "+ phy.getNumberOfStudent());
       Student[] physt=phy.getStudents();
       System.out.printf("%10s\t%10s\n","NAME","ID");
       for(int i=0;i<phy.getNumberOfStudent();i++)
       {
           System.out.printf("%10s\t",physt[i].getName());
           System.out.printf("%10s\t\n",physt[i].getId());
       }
      
   }
}

Output Screenshot--

Note--

Please upvote if you like the effort.


Related Solutions

You are asked to design a relational database for a simple course registration software application for...
You are asked to design a relational database for a simple course registration software application for your school. The relational database must have the following information about the student, the course, and the registration, respectively StudentID, FirstName, LastName, DataOfJoining, and Major CourseNumber, CourseName,InstructorName, StartDate, EndDate, NumberOfCredits ReferenceID, StudentID,CourseID, DateOfRegistration Apply the following constrains while designing the database Each student in the database must be uniquely identifiable Each course listed in the database must be have unique CourseNumber Each course registration...
Design a role-based access control system. Thank you. Will leave a great rating A course registration...
Design a role-based access control system. Thank you. Will leave a great rating A course registration system is a computer system used by the university's administration to plan courses, for students to register for courses, and for faculty to grade them. Students and faculty can only enroll or teach a class if they have been recorded in the registration system. Students are entered into the system by and Admissions representatives; faculty members by a Human Resources employee. For all persons,...
Plot a Package Diagram for the Online Student Registration System. Use the Package Diagram class-based syntax.
Plot a Package Diagram for the Online Student Registration System. Use the Package Diagram class-based syntax.
USING JAVA, PLEASE MAKE THIS AS SIMPLE AS POSSIBLE, THIS IS AN INTRODUCTORY JAVA COURSE 1....
USING JAVA, PLEASE MAKE THIS AS SIMPLE AS POSSIBLE, THIS IS AN INTRODUCTORY JAVA COURSE 1. Design and implement a class called PairOfDice. The class should include: a. A non-default constructor, i.e. with parameters b. A setter method for each instance data c. A getter method for each instance data d. A method roll() that rolls both dice e. A toString() method that returns a string containing the colors of both dice, eg "Colors of both dice: Red,Blue " f....
Evaluate the course registration system at your university. List the basic steps of a user’s dialog...
Evaluate the course registration system at your university. List the basic steps of a user’s dialog with the system. What are some of the problems with the system from the perspective of ease of learning and ease of use? In what ways is the system inflexible? In what ways is needed information not available? Is too much information provided that distracts from the task at hand? [1] 2. Create a word processing document using your favorite word processor. At the...
Java - Design and implement an application that creates a histogram that allows you to visually...
Java - Design and implement an application that creates a histogram that allows you to visually inspect the frequency distribution of a set of values. The program should read in an arbitrary number of integers that are in the range 1 to 100 inclusive; then produce a chart similar to the one below that indicates how many input values fell in the range 1 to 10, 11 to 20, and so on. Print one asterisk for each value entered. Sample...
Create a description of a university course registration system. You should include features for students, faculty,...
Create a description of a university course registration system. You should include features for students, faculty, and administrators. For example, students need to use the system to add and drop courses that they attend, faculty needs to add and drop courses that they offer and the Registrar needs to allocate and de-allocate resources for courses that are added or dropped. Each type of user also has to satisfy some constraints, such as how many courses they take (students), teach (faculty)...
Design a program in JAVA that allows you to experiment with different sort algorithms. The algorithms...
Design a program in JAVA that allows you to experiment with different sort algorithms. The algorithms are shell sort and quick sort. Assume that input data is stored in a text file. Experimenting with a prototype data (integers from 1 to 10) to ensure that your implementation works correctly and the results match expectations. The program will sort what is in the text file and print the amount of comparisons and exchanges for both algorithms.
java 8.3: Histogram Design and implement an application that creates a histogram that allows you to...
java 8.3: Histogram Design and implement an application that creates a histogram that allows you to visually inspect the frequency distribution of a set of values. The program should read in an arbitrary number of integers that are in the range 1 to 100 inclusive; then produce a chart similar to the one below that indicates how many input values fell in the range 1 to 10, 11 to 20, and so on. Print one asterisk for each value entered....
Write a program in Java Design and implement simple matrix manipulation techniques program in java. Project...
Write a program in Java Design and implement simple matrix manipulation techniques program in java. Project Details: Your program should use 2D arrays to implement simple matrix operations. Your program should do the following: • Read the number of rows and columns of a matrix M1 from the user. Use an input validation loop to make sure the values are greater than 0. • Read the elements of M1 in row major order • Print M1 to the console; make...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT