JAVA

PART -A

PROGRAM 1 PROGRAM 2 PROGRAM 3 PROGRAM 4 PROGRAM 5 PROGRAM 6 PROGRAM 7

PART-B

PROGRAM B1 PROGRAM B2 PROGRAM B3 PROGRAM B4 PROGRAM B5 PROGRAM B6 PROGRAM B7 PROGRAM B8 . . .

6.

 
  
 
 
 6.Write a Java program to read name, register number, date of birth, address, phone number a student. Concatenate these to frame a single content by delimiting each detail with a special symbol, pass it to a method which should separate and display the details of the student. Declare a class containing the following methods:
 
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class P6{

public static void main(String[] args) {
        // creating objects st1 and st2 of class Student
        int sizeN=5;
        Student[] st = new Student[5];
        int choice=0,i=0;
       st[0]=new Student("Raj");
       st[1]=new Student("RAVi");     
       st[2]=new Student("NAVEEN");
       st[3]=new Student("RAMYA");
       st[4]=new Student("AMRUTHA");

  try{
     System.out.println("Student Details  ");
  
     BufferedReader reader =new BufferedReader(new InputStreamReader(System.in));
     
        i=0;
        
        while(true){
      System.out.println("Enter Choice 1: getinformation , 2:Display  info (extract)  3: EXIT");
     choice = Integer.parseInt(reader.readLine());
     boolean shouldBreak = false;
       
         switch(choice)
        { 
                case 1:  if(i< sizeN) {
                         System.out.println("Enter Choice 1:"+i); 
                        st[i].getInformation();
                        i++;}
                        
                 break;
                case 2:
                 System.out.println( "  DISPLAY INFORMATION ");
                      for (j=0;j< sizeN;j++){
                         st[j].extractInformation();
                      }
                break;
                   case 3:
                    shouldBreak=true;
                   break;
            
                }
                 if (shouldBreak) break;
                            
          }
        }catch(Exception e){}
    }// end of main


}

 class  Student {   
    private String name;
    private String Registernumber;
    private String Mobilenumber;
    private String dateofbirth;
    private   String MergredText;
    
   public  static String year="2021";
   public static int cycle=2;
   public static int count=0;
    
     
    public Student(){}
    public Student(String name){
       this.name=name;
       this.generateRegisternumber();
    }


    public void getInformation(){
        try{
        BufferedReader reader =new BufferedReader(new InputStreamReader(System.in));
          System.out.println("Enter Name : ");
         this.name= reader.readLine();       
         System.out.println("Enter mobilenumber : ");
         this.Mobilenumber= reader.readLine();
        System.out.println("Enter dateofbirth : ");
         this.dateofbirth= reader.readLine();

        
        System.out.println("Entry Succefully   : ");
        this.generateRegisternumber();
         this.concatenate();
         }catch(Exception e){
        }
        
       
    }
    
      public void concatenate(){
        
        StringBuilder sbStudent = new StringBuilder();
                 Student. count++;
                sbStudent.append(this.name);
             sbStudent.append(":");
          sbStudent.append(this.Mobilenumber);
        sbStudent.append(":");
        sbStudent.append(this.dateofbirth);
        sbStudent.append(":");
        sbStudent.append(this.Registernumber);
        this.MergredText=sbStudent.toString();
    }




    public void generateRegisternumber(){
        StringBuilder sbStudent = new StringBuilder();
        
        Student. count++;
        
        sbStudent.append("BC");
        sbStudent.append(Student.year);
        sbStudent.append(Student.cycle);
        sbStudent.append(String.format("%03d", Student.count));
        this.Registernumber=sbStudent.toString();
    }


  public void extractInformation(){

       String value[]= this.MergredText.split(":",5);
       System.out.println("student Name : "+value[0]);
       System.out.println("student Mobilenumber : "+value[1]);
       System.out.println("student dateofbirth : "+value[2]);
       System.out.println("student Registernumber : "+value[3]);
        }


   
   

 public void displayRegisterd(){
  System.out.println(this.name+"  : " +Student.year+":"+Student.cycle+":"+this.Registernumber);

}
}