can someone help me witht the following program Write a Java
can someone help me witht the following program.
Write a Java program which will store, manipulate, and print student registration information.
As part of the solution, identify the following classes:
Student
Admissions.
The class Student must have the following fields – Name, Address, Id number, Courses, and Date, where:
Name is a user defined class comprising of at minimum first name and last name.
Address is a user defined class comprising of fields - street, city, state, and zip code.
Date is a predefined class in the java.util package
The field Courses is a set of no more than five (5) string values representing the courses being registered for. Course names supplied are assumed to be valid and contains no blank space, for instance COP3337 is valid but not COP 3337.
Id number a string variable that uniquely identifies a student.
The class Student must be capable of adding courses and dropping courses
The class Admissions stores and manipulates the student information (student record). Because the list of students grows dynamically, it is best to use a dynamic data structure such as the ArrayList to store the information. This class should do the following, among other possible activities:
Add student to the list
Remove student from the list, which would first involve locating the record in order to remove it. In order to determine which record to remove you must supply the Id number as the search argument.
You are to provide a test class that coordinates the activities of the classes outlined above, by:
Creating student objects and adding them to the database of the Admissions object
Manipulating student record by:
Adding a course(s)
Dropping a course(s)
Removing a student from the database
Displaying list of currently registered students
Displaying list of all students that were dropped from the course
Display the output in a scrollable pane, and must be formatted as follows:
CURRENTLY ENROLLED
Id number: 123456
Name: Williams, John
Address: 2525 Hartsfield Road
Tallahassee, FL 33319
Date: September 5, 2009
Courses: COP3804, MATH2050, ENG3300
:
:
:
STUDENT WHO WERE DROPPED
Id number: 567890
Name: Roberts, Kay-Anne
Date: September 5, 2009
:
:
Note: Use the class GetData provided to enter the data from the keyboard.
import javax.swing.JOptionPane;
class GetData
{
static double getDouble(String s)
{
return Double.parseDouble(getWord(s));
}
static int getInt(String s)
{
return Integer.parseInt(getWord(s));
}
static String getWord(String s)
{
return JOptionPane.showInputDialog(s);
}
}
The method display shown below shows how to display information in a scrollable pane. Listing 1.8 of text shows how the class GetData and the method display are implemented within a program.
ive finished the student class however for some reason there are a few errors. could someone help me fix the errors as well as finish the admissions class please. this is what I have so far.
package student;
import java.util.ArrayList;
import java.util.Date;
public class Student {
ArrayList<Courses> currentCourses = new ArrayList<courses>();
ArrayList<Courses> droppedCourses = new ArrayList<courses>();
private Name name;
private Address address;
private String id_num;
private Date date;
private Courses courses;
public Student (Name name, Address address,
String id_num, Date date, Courses courses)
{
this.name = name ;
this.address = address;
this.id_num = id_num;
this.date = date;
this.courses = courses;
}
public Name getName() {
return name;
}
public Address getAddress() {
return address;
}
public String getIDnumber() {
return id_num;
}
public Date getDate() {
return date;
}
public Courses getCourses() {
return courses;
}
public void setName (Name newName){
name = newName;
}
public void setAddress (Address newAddress){
address = newAddress;
}
public void setIDnumber (String newIDnumber){
id_num = newIDnumber;
}
public void setCourses (Courses newCourses){
courses = newCourses;
}
public void setDate (Date newDate){
date = newDate;
}
public Boolean EnrollCourse (Courses newCourse){
if (currentCourses.size() > 6) {
return false;
} else {
currentCourses.add(newCourse);
return true;
}
}
public Boolean Remove (Courses dropCourse) {
if (currentCourses.isEmpty()) {
System.out.println(\"You are not enrolled in any courses\");
return false;
}else if (!currentCourses.contains(dropCourse)) {
System.out.println(\"You are not enrolled in this course\");
return false;
}else if (currentCourses.contains(dropCourse)) {
System.out.println(\"This course was already dropped\");
return false;
}else {
currentCourses.remove(dropCourse);
droppedCourses.add(dropCourse);
System.out.println(\"The course was successfully dropped\");
return true;
}
}
}
please help
| import javax.swing.JOptionPane; class GetData { static double getDouble(String s) { return Double.parseDouble(getWord(s)); } static int getInt(String s) { return Integer.parseInt(getWord(s)); } static String getWord(String s) { return JOptionPane.showInputDialog(s); } } |
Solution
------------------------------------------------------------------------
Student.java
------------------------------------------------------------------------
package student;
import java.util.ArrayList;
import java.util.Date;
public class StudentServices {
static ArrayList<Student> studentList = new ArrayList<Student>();
static ArrayList<String> coursesOffered = new ArrayList<String>();
ArrayList<String> droppedCourses = new ArrayList<String>();
public static void main(String args[]) {
/*A student1 details has been added to studentList as initial data */
Student student1 = new Student();
Name name1 = new Name();
name1.setFirstName(\"John\");
name1.setLastName(\"Williams\");
student1.setName(name1);
Address address1 = new Address();
address1.setStreet(\"2525 Hartsfield Road\");
address1.setCity(\"Tallahassee\");
address1.setState(\"FL\");
address1.setZipCode(\"33319\");
student1.setAddress(address1);
student1.setDate(new Date());
coursesOffered.add(\"COP331\");
coursesOffered.add(\"CG332\");
coursesOffered.add(\"SP333\");
coursesOffered.add(\"DAA334\");
student1.setCourses(coursesOffered);
student1.setIDnumber(1);
studentList.add(student1);
/*Call all operation using studentServices object */
StudentServices studentServices = new StudentServices();
studentServices.getAllStudent();
}
public Boolean EnrollCourse(ArrayList<String> newCourse) {
if (coursesOffered.size() > 6) {
return false;
} else {
coursesOffered.addAll(newCourse);
return true;
}
}
public Boolean Remove(ArrayList<String> dropCourse) {
if (coursesOffered.isEmpty()) {
System.out.println(\"You are not enrolled in any courses\");
return false;
} else if (!coursesOffered.contains(dropCourse)) {
System.out.println(\"You are not enrolled in this course\");
return false;
} else if (droppedCourses.contains(dropCourse)) {
System.out.println(\"This course was already dropped\");
return false;
} else {
coursesOffered.remove(dropCourse);
droppedCourses.addAll(dropCourse);
System.out.println(\"The course was successfully dropped\");
return true;
}
}
public Student addStudent(Student student) {
student.setIDnumber(studentList.size() + 1);
studentList.add(student);
return student;
}
public boolean removeStudent(String idNumber) {
return studentList.remove(idNumber);
}
public ArrayList<Student> getAllStudent() {
for (Student s : studentList) {
System.out.println(\"Id number: \" + s.getIDnumber());
System.out.println(\"Name:\" + s.getName());
System.out.println(\"Address:\" + s.getAddress());
System.out.println(\"Date:\" + s.getDate());
System.out.println(\"Courses:\" + s.getCourses());
}
return new ArrayList<Student>(studentList);
}
}
------------------------------------------------------------------------
Name.java
------------------------------------------------------------------------
package student;
public class Name {
private String firstName;
private String lastName;
public String getFirstName() {
return firstName;
}
public void setFirstName(String firstName) {
this.firstName = firstName;
}
public String getLastName() {
return lastName;
}
public void setLastName(String lastName) {
this.lastName = lastName;
}
}
------------------------------------------------------------------------
Address.java
------------------------------------------------------------------------
package student;
public class Address {
private String street;
private String city;
private String state;
private String zipCode;
public String getStreet() {
return street;
}
public void setStreet(String street) {
this.street = street;
}
public String getCity() {
return city;
}
public void setCity(String city) {
this.city = city;
}
public String getState() {
return state;
}
public void setState(String state) {
this.state = state;
}
public String getZipCode() {
return zipCode;
}
public void setZipCode(String zipCode) {
this.zipCode = zipCode;
}
}






