Answer to Question #268726 in Java | JSP | JSF for Mohammad

Question #268726

Write java application with the following information:


- Class Name ; Student


- Method1: AddStudent


- Method2: Print Students


- Method 3: totalStudent


- Method 4: Delete Student

1
Expert's answer
2021-11-19T14:42:45-0500
public class Main
{
	public static void main(String[] args) {
		Student  s=new Student();
		s.addStudent(0,123,"abc");
		s.addStudent(0,124,"efg");
		s.addStudent(0,125,"hij");
		s.printStudents();
		s.totalStudents();
		s.deleteStudent();
		s.printStudents();
		s.totalStudents();
	}
}


class Student{
    private int [] student_id=new int[100];
    private String [] student_name=new String [100];
    int count=0;
    public void addStudent(int i,int id,String name){
       student_id[i]=id;
       student_name[i]=name;
       count++;
    }
    public void printStudents(){
        for(int i=0;i<count;i++){
            System.out.println("ID\tName");
            System.out.println(student_id[i]+"\t"+student_name[i]);
        }
    }
    public void totalStudents(){
        System.out.println("Total number of students is "+count);
    }
    public void deleteStudent(){
        count--;
    }
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS