import java.io.*; public class StuDetail { int RollNo; } class StudMarks extends StuDetail { float sub1; float sub2; float sub3; float TotalMarks; StudMarks(int SMobj) { } void getData() { System.out.println("\nRecording Entry"); try { BufferedReader obj=new BufferedReader(new InputStreamReader(System.in)); String sRNo,sSub1,sSub2,sSub3; System.out.println("Enter Roll No:"); System.out.flush(); sRNo=obj.readLine(); RollNo=Integer.parseInt(sRNo); System.out.println("Enter Marks for Subject 1:"); System.out.flush(); sSub1=obj.readLine(); sub1=Float.parseFloat(sSub1); System.out.println("Enter Marks for Subject 2:"); System.out.flush(); sSub2=obj.readLine(); sub2=Float.parseFloat(sSub2); System.out.println("Enter Marks for Subject 3:"); System.out.flush(); sSub3=obj.readLine(); sub3=Float.parseFloat(sSub3); TotalMarks=sub1+sub2+sub3; } catch(Exception e) {} } void display() { System.out.println("\nDisplaying Record"); System.out.println("Roll No:"+RollNo); System.out.println("Subject 1:"+sub1); System.out.println("Subject 1:"+sub2); System.out.println("Subject 1:"+sub3); System.out.println("Total Marks:"+TotalMarks); } void TotalMarks() { System.out.println("\nDisplaying Record"); System.out.println("Roll No:"+RollNo); System.out.println("Total Marks:"+TotalMarks); } }
import java.io.BufferedReader; import java.io.InputStreamReader; public class StudentDatabase { public static void main(String []args) { System.out.println("\n======STUDENT DATABASE=====\n"); float HighMark_sub1; float HighMark_sub2; float HighMark_sub3; float StudHightMark; int No_of_stud=3,choice; String str; char c; try { BufferedReader obj=new BufferedReader(new InputStreamReader(System.in)); System.out.print("\nEnter number of students:"); System.out.flush(); str=obj.readLine(); No_of_stud=Integer.parseInt(str); StudMarks SMobj[]=new StudMarks[No_of_stud]; while(true) { System.out.println("\nChoose your choice...."); System.out.println("1)PASS ENTRY"); System.out.println("2)DISPLAY ALL RECORDS"); System.out.println("3)DISPLAT TOTAL MARKS for all students"); System.out.println("4)DISPLAT HIGHEST MARKS in each subject"); System.out.println("5 DISPLAY student who recived highest total marks"); System.out.println("6 Exit"); System.out.println("ENTER YOUR CHOICE:"); System.out.flush(); str=obj.readLine(); choice=Integer.parseInt(str); switch(choice) { case 1: for(int i=0; i<No_of_stud; i++) { SMobj[i] = new StudMarks(i); SMobj[i].getData(); } break; case 2: for(int i=0; i<No_of_stud; i++) { SMobj[i] = new StudMarks(i); SMobj[i].display(); } break; case 3: for(int i=0; i<No_of_stud; i++) { SMobj[i] = new StudMarks(i); SMobj[i].TotalMarks(); } break; case 4:break; case 5:break; case 6:System.out.println("\nThanks for visting....."); System.exit(1); } } } catch(Exception e) { e.printStackTrace();} } }
void display() { System.out.println("\nDisplaying Record"); System.out.println("Roll No:"+RollNo); System.out.println("Subject 1:"+sub1); System.out.println("Subject 1:"+sub2); System.out.println("Subject 1:"+sub3); System.out.println("Total Marks:"+TotalMarks); }
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre questionSystem.out.println("4)DISPLAT HIGHEST MARKS in each subject"); System.out.println("5 DISPLAY student who recived highest total marks");