


Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
public static void main(String[] args) {. // TODO Auto-generated method stub. Student s=new Student(1,ali,2.5);. CourseManager5 cs111=new CourseManager5 ...
Typology: Schemes and Mind Maps
1 / 4
This page cannot be seen from the preview
Don't miss anything!



public class testst {
public static void main(String[] args) { // TODO Auto-generated method stub Student s=new Student(1,"ali",2.5); CourseManager5 cs111=new CourseManager5(); cs111.addstudent(s); cs111.addstudent3(); if(!cs111.dispalyStudent(2)) System.out.println("not found"); System.out.println("the sutdent that have the minimum score is "+ cs111.findnameofthestudentthathavetheminimumscore());
}
import java.util.Scanner;
public class CourseManager5 { private Student[] students; private int nStudents; public static final int MAX_SIZE=100; Scanner s=new Scanner(System.in); public CourseManager5() { students=new Student[MAX_SIZE]; nStudents=0; } public int getnStudents() { return nStudents; } void addstudent(Student newstudent) { if(nStudents<students.length) { students[nStudents]=newstudent; nStudents++; } } boolean addstudent2(Student newstudent) { if(nStudents<students.length) { students[nStudents]=newstudent; nStudents++;
return true; } return false; } boolean addstudent3() { if(nStudents<students.length) { System.out.println("enter student id, name, score"); students[nStudents]=new Student(s.nextInt(),s.next(),s.nextDouble()); nStudents++; return true; } return false; } boolean addstudent4(int id,String n,double s) { if(nStudents<students.length) { students[nStudents]=new Student(id,n,s); nStudents++; return true; } return false; } int Searchbyid(int id) { for(int i=0;i<nStudents;i++) if(id==students[i].getId()) return i; return -1; } boolean drop(int id) { int index=Searchbyid(id); if(index==-1) return false; //delete students[index]=students[nStudents-1]; nStudents--; students[nStudents]=null; return true; } boolean drop2(int id) {
public Student(int id, String name, double score) { this.id = id; this.name = name; this.score = score; } public int getId() { return id; } public String getName() { return name; } public double getScore() { return score; }
}