public class testst, Schemes and Mind Maps of Object Oriented Programming

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

2022/2023

Uploaded on 03/01/2023

jugnu900
jugnu900 🇺🇸

4.4

(7)

235 documents

1 / 4

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
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++;
pf3
pf4

Partial preview of the text

Download public class testst and more Schemes and Mind Maps Object Oriented Programming in PDF only on Docsity!

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; }

}