Please open the menu to show more

Thursday, August 3, 2017

Solution for the assignment (student information) of 10 to 12 batch given on 3rd, August, 2017

This solution is implemented and provided by 
=>  ITI Dixit 
=>  Computer Science 
=>  Banasthali University (Jaipur)


# save this class inside StudentInformationSystem .java file #

import java.util.*;

public class StudentInformationSystem 
{
    public static void main(String[] args)
    {
        Scanner sc=new Scanner(System.in);
        //take size of array as an input from the user
        System.out.println("ENTER SIZE : ");
        //array declaration 
        int size=sc.nextInt();
        int[] roll=new int[size];
        String[] name=new String[size];
        int[] age=new int[size];
        int[] marks=new int[size];
        //taking details of students as an input from the user
        System.out.println("ENTER ROLL NUMBERS : ");
        for(int i=0;i<size;i++) {
System.out.print("enter roll number of student "+(i+1)+":");
            roll[i]=sc.nextInt();
}
         System.out.println("-----------------------------------------------");
        System.out.println("ENTER NAMES : ");
       
        for(int i=0;i<size;i++) {
System.out.print("enter name of student "+(i+1)+":");
name[i]=sc.next();
}
                    
          System.out.println("-----------------------------------------------");
        System.out.println("ENTER AGE : ");
        for(int i=0;i<size;i++) {
System.out.print("enter age of student "+(i+1)+":");
       age[i]=sc.nextInt();
        }
System.out.println("-----------------------------------------------");
        System.out.println("ENTER MARKS : ");
        for(int i=0;i<size;i++) {
System.out.print("enter marks of student "+(i+1)+":");
            marks[i]=sc.nextInt();
}
         System.out.println("-----------------------------------------------");
         //display of details of all the students
         System.out.println("ROLL NO. \t NAME \t AGE \t MARKS");
         for(int i=0;i<size;i++) {
           System.out.println(roll[i]+"\t\t"+name[i]+"\t"+age[i]+"\t"+marks[i]);
}
        System.out.println("-----------------------------------------------");
int option = 1;
while(true) {
        //taking user's choice as an input from the user according to the menu
        System.out.println("ENTER YOUR CHOICE : \n1.FIND BY ROLL NUMBER \n2.FIND BY AGE \n"
                + "3. FIND BY MARKS RANGE \n4. DETAILS OF STUDENT WITH MAXIMUM MARKS \n"
                + "5. DETAILS OF STUDENT WITH MIMIMUM MARKS");
System.out.println(">>>>>input 0 to terminate the program<<<<<");
        int ch=sc.nextInt();
if(ch==0) {
break;
}
        switch(ch) {
            case 1:
                //taking roll number as an input whose details are to be displayed
                System.out.println("ENTER THE ROLL NUMBER WHOSE DETAILS IS TO BE SEARCHED : ");
                int r=sc.nextInt();
                for(int i=0;i<size;i++)
                {
                    if(roll[i]==r)     
                    {
                        System.out.println("DETAILS : \n NAME : "+name[i]+"\n AGE : "+age[i]+"\n MARKS : "+marks[i]);
                    }
                    
                }
                break;
            case 2:
                //taking age as an input whose details are to be displayed
                System.out.println("ENTER THE AGE WHOSE DETAILS IS TO BE SEARCHED : ");                               
                int a=sc.nextInt();
                for(int i=0;i<size;i++)
                {
                    if(age[i]==a)
                    {
                        System.out.println("DETAILS : \n ROLL NUMBER : "+roll[i]+"\n NAME : "+name[i]+"\n MARKS : "+marks[i]);
                    }
                    
                }
                break;
            case 3:
                /*taking range of marks as an input such that details of students having
                  marks lying between the range are displayed
                */
                  
                System.out.println("ENTER THE RANGE OF MARKS : ");
                int m=sc.nextInt();
                int n=sc.nextInt();
                //range should be between 0 to 100
                if(m>=0 && n<=100)
                {
                for(int i=0;i<size;i++)
                {
                    if(marks[i]>m && marks[i]<n)
                     System.out.println("DETAILS : \n ROLL NUMBER : "+roll[i]+"\n NAME : "+name[i]+"\n AGE : "+age[i]);
                }
                }
                else
                    System.out.println("INVALID RANGE");
                break;
            case 4:
                //variable to store maximum marks
                int max=marks[0];
                //calculation of max marks
                for(int i=0;i<size;i++)
                {
                    if(marks[i]>max)
                        max=marks[i];
                }
                //display of details of student with max marks
                for(int i=0;i<size;i++)
                {
                    if(marks[i]==max)
                    System.out.println("DETAILS : \n ROLL NUMBER : "+roll[i]+"\n NAME : "+name[i]+"\n AGE : "+age[i]);
                }
                break;
            case 5:
                //variable to store min marks
                int min=marks[0];
                //calculation of min marks
                for(int i=0;i<size;i++)
                {
                    if(marks[i]<min)
                        min=marks[i];
                }
                //display of details of student with min marks
                for(int i=0;i<size;i++)
                {
                    if(marks[i]==min)
                      System.out.println("DETAILS : \n ROLL NUMBER : "+roll[i]+"\n NAME : "+name[i]+"\n AGE : "+age[i]);  
                }
                break;
            default:
                System.out.println("INVALID CHOICE");
                
        }
       
}
        
    }
}

2 comments:

  1. Thanks for sharing this good blog.This is very important and imformative

    blog for Java . very interesting and useful for students
    Java Online Training

    ReplyDelete
  2. Australia Best Tutor is providing online assignment help services at affordable prices. Here students are coming for better grades and improve your results. These services are available 24 x 7 hours. List are under below.
    Online Assignment Help
    Assignment Help
    Instant Assignment Help
    My Assignment Help
    Help with Assignment


    ReplyDelete