domxaline | bonjour
je besoin vos aides;je ne sais pas construire une partie de mon prg aidez moi
"display highest marks"
"display student who received highest marks"
Code :
- import java.io.*;
- public class StuDetail
- {
- int RollNo;
- }
- class StudMarks extends StuDetail
- {
- float sub1;
- float sub2;
- float sub3;
- float TotalMarks;
- float max=0,max1=0,max2=0,max3=0,tmp=0;
- 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("Roll No:"+RollNo);
- 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;
- System.out.println("TotalMarks"+TotalMarks);
- }
- 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 2:"+sub2);
- System.out.println("Subject 3:"+sub3);
- System.out.println("Total Marks:"+TotalMarks);
- }
- void TotalMarks()
- {
- System.out.println("\nDisplaying ToalMarks" );
- System.out.println("Roll No:"+RollNo);
- System.out.println("Total Marks:"+TotalMarks);
- }
- void HighestMarks()
- {
- for(int j=0;j<RollNo;j++)
- {
- max=0;
- for(int i=0;i<3;i++)
- {
- if (RollNo>max)
- {
- max1=RollNo;
- }
-
- }
- System.out.println("" );
- System.out.println("*******Highest marks in each subject with roll no******" );
- for(int i=0;i<RollNo;i++)
- {
-
- }
-
- }
- void StudHighestMarks()
- {
-
- }
-
- }
- import java.io.BufferedReader;
- import java.io.InputStreamReader;
- public class StudentDatabase
- {
- public static void main(String []args)
- {
- System.out.println("======STUDENT DATABASE=====" );
- 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:
- System.out.printf("#%d\n",No_of_stud);
- for(int i=0; i<No_of_stud; i++)
- {
- SMobj[i].display();
- }
- break;
- case 3:
- System.out.printf("#%d\n",No_of_stud);
- for(int i=0; i<No_of_stud; i++)
- {
- SMobj[i].TotalMarks();
- }
- break;
- case 4:
- System.out.printf("#%d\n",No_of_stud);
- for(int i=0; i<No_of_stud; i++)
- {
- SMobj[i].HighestMarks();
- }
- break;
- case 5:
- System.out.printf("#%d\n",No_of_stud);
- for(int i=0; i<No_of_stud; i++)
- {
- SMobj[i].StudHighestMarks();
-
- }
- break;
- case 6:System.out.println("\nThanks for visting....." );
- System.exit(1);
- }
- }
- }
- catch(Exception e)
- { e.printStackTrace();}
- }}
|
|