The problem is in the picture and please give me a complete program and ill rate
ID: 3544387 • Letter: T
Question
The problem is in the picture and please give me a complete program and ill rate 5 star !!
Thanks
Each student at Middlesex County College takes a different number of courses, so the registrar has decided to use linear linked lists to store each student's class schedule and an array to represent the entire student body These data show that the first student (ID: 1111) is taking section 1 of CSC162 for 3 credits and section 2 of HIS101 for 4 credits; the second student is not enrolled; the third student is enrolled in CSC236 section 4 for 3 credits. Write a class for this data structure. Provide methods for creating the original array, inserting a student's initial class schedule, adding a course, and dropping a course. Include a menu-driven program that uses the class.Explanation / Answer
import java.util.Scanner;
public static void main(String [ ] args)
{
students[] theStudents = new students[1000];
int a,k;
String cour;
k=0;
a=0;
Scanner in = new Scanner(System.in);
System.out .println("Enter 1 to add a new Student");
System.out.println("Enter 2 to edit the courses of existing students");
System.out.println("Enter 3 to exit");
while(k!=3){
k = in.nextInt();
if(k==1){
System.out .println("Enter the student id");
k = in.nextInt();
student stud=new student();
stud.id=k;
theStudents[a]=stud;
a=a+1;
}else if(k==2){
System.out .println("Enter the student id");
k = in.nextInt();
int b<0;
while(b<a){
if(k==theStudents[b]){
break;
}
b++;
}
if(a==b){
System.out .println("No Such Student exists");
}else{
System.out .println("Enter 1 to add the course");
System.out .println("Enter 2 to add the course");
k = in.nextInt();
if(k==1){
course abc=new course();
System.out .println("Enter the course id");
abc.course_id=in.nextLine();
System.out .println("Enter the section");
abc.section=in.nextInt();
System.out .println("Enter the credits");
abc.credits=in.nextInt();
if(theStudents[b].course1==null){
theStudents[b].course1=abc;
}else{
abc.nex_course=theStudents[b].course1;
theStudents[b].course1=abc;
}
}else if(k==2){
System.out .println("Enter the course id");
cour=in.nextLine();
Course fgh=new course();
Course fgh_prev=new course();
fgh=theStudents[b].course1;
while(fgh!=null){
if(cour.equals(fgh.course_id)){
if(fgh_prev==null){
theStudents[b].course1=null;
}else{
fgh_prev.nex_course=fgh.nexcourse;
break;
}
}
fgh_prev=fgh;
fgh=fgh.nex_course;
}
}
}
}
}
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.