Professional Documents
Culture Documents
package javaProject;
import java.util.Scanner;
class Student50{
int rollno;
String name;
String college;
class StudDemo{
public static void main(String[] args) {
int count=0;
int choice=0;
int rollno;
String name;
String college;
Scanner sc=new Scanner(System.in);
do {
System.out.println("\nStudent Management System\
n**************************************\n");
System.out.println("Enter: 1. For insert \n\t2. For update \
n\t3. For delete \n\t4. Select all \n\t0. For exit");
choice=sc.nextInt();
switch(choice) {
case 1:
roll[count]=rollno;
nm[count]=name;
clg[count]=college;
System.out.println("\nStudent record added successfully
!!!\n");
count++;
break;
case 2:
System.out.println("Enter roll no for updating student
data:");
rollno=sc.nextInt();
boolean isPresent = false;
for(int i=0;i<count;i++) {
if(roll[i]!=0 && roll[i]==rollno) {
System.out.println("\nStudent record
updated successfully !!!\n");
isPresent = true;
}
}
if(!isPresent) {
System.out.println("Roll number "+rollno+" is not
exist !!!");
}
break;
case 3:
System.out.println("Enter roll no for deleting
data :");
rollno=sc.nextInt();
boolean isPresent1 = false;
for(int i=0;i<count;i++) {
if(roll[i]!=0 && roll[i]==rollno) {
roll[i]=0;
nm[i]=null;
clg[i]=null;
System.out.print("\nStudent record deleted
successfully !!!\n");
isPresent1 = true;
}
}
if(!isPresent1) {
System.out.println("Roll number "+rollno+" is not
exist !!!");
}
break;
case 4:
for(int i=0;i<count;i++) {
if(roll[i]!=0) {
System.out.println(roll[i]+" "+nm[i]+"
"+clg[i]);
}
}
break;
case 0:
break;
default:
System.out.println("Enter valid choice.....");
break;
}while(choice!=0);
sc.close();
}
}