je suis bloqué dans une partie de mon prg

je suis bloqué dans une partie de mon prg - Java - Programmation

Marsh Posté le 10-05-2012 à 18:00:34    

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 :
  1. import java.io.*;
  2. public class StuDetail
  3. {
  4.   int RollNo;
  5. }
  6. class StudMarks extends StuDetail
  7. {
  8. float sub1;
  9. float sub2;
  10. float sub3;
  11. float TotalMarks;
  12. float max=0,max1=0,max2=0,max3=0,tmp=0;
  13. StudMarks(int SMobj)
  14. {
  15. }
  16. void getData()
  17. {
  18.  System.out.println("\nRecording Entry" );
  19.  try
  20.  {
  21.   BufferedReader obj=new BufferedReader(new InputStreamReader(System.in));
  22.   String sRNo,sSub1,sSub2,sSub3;
  23.   System.out.println("Enter Roll No:" );
  24.   System.out.flush();
  25.   sRNo=obj.readLine();
  26.   RollNo=Integer.parseInt(sRNo);
  27.   System.out.println("Roll No:"+RollNo);
  28.   System.out.println("Enter Marks for Subject 1:" );
  29.   System.out.flush();
  30.   sSub1=obj.readLine();
  31.   sub1=Float.parseFloat(sSub1);
  32.   System.out.println("Enter Marks for Subject 2:" );
  33.   System.out.flush();
  34.   sSub2=obj.readLine();
  35.   sub2=Float.parseFloat(sSub2);
  36.   System.out.println("Enter Marks for Subject 3:" );
  37.   System.out.flush();
  38.   sSub3=obj.readLine();
  39.   sub3=Float.parseFloat(sSub3);
  40.   TotalMarks=sub1+sub2+sub3;
  41.   System.out.println("TotalMarks"+TotalMarks);
  42.  }
  43.  catch(Exception e)
  44.  {}
  45.  }
  46.     void display()
  47.     {
  48.      System.out.println("\nDisplaying Record" );
  49.      System.out.println("Roll No:"+RollNo);
  50.      System.out.println("Subject 1:"+sub1);
  51.      System.out.println("Subject 2:"+sub2);
  52.      System.out.println("Subject 3:"+sub3);
  53.      System.out.println("Total Marks:"+TotalMarks);
  54.  }
  55.     void TotalMarks()
  56.     {
  57.      System.out.println("\nDisplaying ToalMarks" );
  58.      System.out.println("Roll No:"+RollNo);
  59.      System.out.println("Total Marks:"+TotalMarks);
  60.     }
  61.     void HighestMarks()
  62.     {
  63.      for(int j=0;j<RollNo;j++)
  64.      {
  65.        max=0;
  66.        for(int i=0;i<3;i++)
  67.        {
  68.       if (RollNo>max)
  69.       {
  70.        max1=RollNo;
  71.       }
  72.    
  73.      }
  74.      System.out.println("" );
  75.      System.out.println("*******Highest marks in each subject with roll no******" );
  76.      for(int i=0;i<RollNo;i++)
  77.      {
  78.    
  79.      }
  80.    
  81.     }
  82.     void StudHighestMarks()
  83.     {
  84.    
  85.     }
  86.    
  87. }
  88. import java.io.BufferedReader;
  89. import java.io.InputStreamReader;
  90. public class StudentDatabase
  91. {
  92. public static void main(String []args)
  93.  {
  94.   System.out.println("======STUDENT DATABASE=====" );
  95.   float HighMark_sub1;
  96.   float HighMark_sub2;
  97.   float HighMark_sub3;
  98.   float StudHightMark;
  99.   int No_of_stud=3,choice;
  100.   String str;
  101.   char c;
  102.   try
  103.   {
  104.   BufferedReader obj=new BufferedReader(new InputStreamReader(System.in));
  105.   System.out.print("\nEnter number of students:" );
  106.   System.out.flush();
  107.   str=obj.readLine();
  108.   No_of_stud=Integer.parseInt(str);
  109.   StudMarks SMobj[]=new StudMarks[No_of_stud];
  110.   while(true)
  111.   {
  112.    System.out.println("\nChoose your choice...." );
  113.    System.out.println("1)PASS ENTRY" );
  114.    System.out.println("2)DISPLAY ALL RECORDS" );
  115.    System.out.println("3)DISPLAT TOTAL MARKS for all students" );
  116.    System.out.println("4)DISPLAT HIGHEST MARKS in each subject" );
  117.    System.out.println("5 DISPLAY student who recived highest total marks" );
  118.    System.out.println("6 Exit" );
  119.    System.out.println("ENTER YOUR CHOICE:" );
  120.    System.out.flush();
  121.    str=obj.readLine();
  122.    choice=Integer.parseInt(str);
  123.    switch(choice)
  124.    {
  125.     case 1:
  126.      for(int i=0; i<No_of_stud; i++)
  127.      {
  128.      SMobj[i] = new StudMarks(i);
  129.      SMobj[i].getData();
  130.      }
  131.      break;
  132.     case 2:
  133.      System.out.printf("#%d\n",No_of_stud);
  134.      for(int i=0; i<No_of_stud; i++)
  135.       {
  136.         SMobj[i].display();
  137.       }
  138.      break;
  139.     case 3:
  140.      System.out.printf("#%d\n",No_of_stud);
  141.      for(int i=0; i<No_of_stud; i++)
  142.      {
  143.       SMobj[i].TotalMarks();
  144.      }
  145.      break;
  146.     case 4:
  147.      System.out.printf("#%d\n",No_of_stud);
  148.      for(int i=0; i<No_of_stud; i++)
  149.      {
  150.       SMobj[i].HighestMarks();
  151.      }
  152.      break;
  153.     case 5:
  154.      System.out.printf("#%d\n",No_of_stud);
  155.      for(int i=0; i<No_of_stud; i++)
  156.      {
  157.       SMobj[i].StudHighestMarks();
  158.        
  159.      }
  160.      break;
  161.     case 6:System.out.println("\nThanks for visting....." );
  162.     System.exit(1);
  163.    }
  164.   }
  165.   }
  166.   catch(Exception e)
  167.   { e.printStackTrace();}
  168. }}

Reply

Marsh Posté le 10-05-2012 à 18:00:34   

Reply

Marsh Posté le 11-05-2012 à 12:34:47    

aidez moi svp,je suis novice svp

Reply

Marsh Posté le 12-05-2012 à 23:03:59    

il manque une accolade dans une de tes fonctions ou c'est un problème de copier coller ? :

Code :
  1. void HighestMarks() {
  2.  for (int j = 0; j < RollNo; j++) {
  3.   max = 0;
  4.   for (int i = 0; i < 3; i++) {
  5.    if (RollNo > max) {
  6.     max1 = RollNo;
  7.    }
  8.   }
  9.  }
  10.  System.out.println("" );
  11.  System.out
  12.    .println("*******Highest marks in each subject with roll no******" );
  13.  for (int i = 0; i < RollNo; i++) {
  14.  }
  15. }


Message édité par SeeMexG le 12-05-2012 à 23:06:06
Reply

Marsh Posté le 13-05-2012 à 18:16:03    

j'avais écrit comme vs m'avez indiquer

Code :
  1. void HighestMarks()
  2.     {
  3.      for(int j=0;j<RollNo;j++)
  4.      {
  5.       max=0;
  6.       for(int i=0;i<3;i++)
  7.       {
  8.        if(RollNo>max)
  9.         max1=RollNo;
  10.       }
  11.       System.out.println("highest marks is:"+max1);
  12.      }
  13.    
  14.      System.out.println("*******Highest marks in each subject with roll no******" );
  15.      for(int i=0;i<RollNo;i++)
  16.      {
  17.    
  18.      }}
  19.    
  20.    
  21.     void StudHighestMarks()
  22.     {
  23.    
  24.     }}


mais le resultat est suivante
Choose your choice....
1)PASS ENTRY
2)DISPLAY ALL RECORDS
3)DISPLAT TOTAL MARKS for all students
4)DISPLAT HIGHEST MARKS in each subject
5 DISPLAY student who recived highest total marks
6 Exit
ENTER YOUR CHOICE:
4
#2
highest marks is:10.0
highest marks is:10.0
highest marks is:10.0
highest marks is:10.0
highest marks is:10.0
highest marks is:10.0
highest marks is:10.0
highest marks is:10.0
highest marks is:10.0
highest marks is:10.0
*******Highest marks in each subject with roll no******
highest marks is:20.0
highest marks is:20.0
highest marks is:20.0
highest marks is:20.0
highest marks is:20.0
highest marks is:20.0
highest marks is:20.0
highest marks is:20.0
highest marks is:20.0
highest marks is:20.0
highest marks is:20.0
highest marks is:20.0
highest marks is:20.0
highest marks is:20.0
highest marks is:20.0
highest marks is:20.0
highest marks is:20.0
highest marks is:20.0
highest marks is:20.0
highest marks is:20.0
merci pour vs aide

Reply

Marsh Posté le 14-05-2012 à 17:59:16    

j'ai reussi faire ce partie

Code :
  1. void HighestMarks()
  2.     {
  3.       max=0;
  4.       for(int i=0;i<3;i++)
  5.       {
  6.        if(sub1>sub2)
  7.         max=sub1;
  8.        else
  9.         max=sub2;
  10.        if (sub2>sub3)
  11.         max=sub2;
  12.        else
  13.         max=sub3;
  14.       }
  15.       System.out.println("highest marks RollNo "+RollNo+" is "+max);
  16.     }


il me restera que partie
DISPLAY student who recived highest total marks
quelqu'un peut m'aider svp


Message édité par domxaline le 14-05-2012 à 18:00:07
Reply

Sujets relatifs:

Leave a Replay

Make sure you enter the(*)required information where indicate.HTML code is not allowed