bonjour
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
import java.util.*;
public class Student 
{
  int rollNo;
  double sub1;
  double sub2;
  double sub3;
  double totalMarks;
  
  public Student(int rollNo,double sub1,double sub2,double sub3,double totalMarks)
  {
	this.rollNo=rollNo;
	this.sub1=sub1;
	this.sub2=sub2;
	this.sub3=sub3;
	this.totalMarks=totalMarks;
  }
  public int getRollNo()
  {
	  return rollNo;
  }
  public double getSub1()
  {
	  return sub1;
  }
  public double getSub2()
  {
	  return sub2;
  }
  public double getSub3()
  {
	  return sub3;
  }
  public double getTotalMarks()
  {
	  return totalMarks;
  }

public static void main (String[]args)
{
	Scanner input=new Scanner(System.in);
	double max1=0,max2=0,max3=0,max=0;
	int no=0;
	double s1=0,s2=0,s3=0,tm=0;
	ArrayList<Student> list=new ArrayList<Student>();
	for(int i=1;i<=2;i++)
	{
	 System.out.print("Enter Roll No:");
	 no=input.nextInt();
	 System.out.print("Enter marks of maths:");
	 s1=input.nextDouble();
	 System.out.print("Enter marks of science:");
	 s2=input.nextDouble();
	 System.out.print("Enter marks of Hindi:");
	 s3=input.nextDouble();
	 tm=s1+s2+s3;
	 list.add(new Student(no,s1,s2,s3,/*s4,s5,*/tm));
	 System.out.println();
	 
	 if(s1>max1)
	 {
	  max1=s1;	 
	 }
	 if(s2>max2)
	 {
	  max2=s2;	 
	 }
	 if(s3>max3)
	 {
	  max3=s3;	 
	 }
	 if(tm>max)
	 {
	  max=tm;	 
	 }}
	 System.out.println("********Roll No and TOTAL Marks*********");
	 System.out.println("Roll No   Total Marks");
	 for(Student s:list)
	 {
		 System.out.println(s.getSub1()+""+s.getSub2());
		 //System.out.println(tm);
	 }
	 System.out.println("");
	 System.out.println("********Highest marks in each subject with RollNo*******");
	 for(Student s:list)
	 {
		 if(s.getSub1()==max1)
		 {
			 System.out.println("Roll No"+s.getRollNo()+"get highest marks in Subject1 i.e"+max1);	 
		 }
	 }
	 for (Student s:list)
	 {
	   if(s.getSub2()==max2)
	   {
		   System.out.println("Roll No"+s.getRollNo()+"get highest marks in Subject 2 i.e"+max2);
	   }
	 }
	 System.out.println("");
	 for (Student s:list)
	 {
	   if(s.getSub3()==max3)
	   {
		   System.out.println("Roll No"+s.getRollNo()+"get highest marks in Subject 3 i.e"+max3);
	   }
	 }
	 System.out.println();
	 System.out.println("*****************Student Obtained Highest Marks**********");
	 for(Student s:list)
	 {
		 if(s.getTotalMarks()==max)
		 {
			 System.out.println("Roll No"+s.getRollNo()+"get highest Marks"); 
		 }
		 
	 }
	 }
	}
resultat:
Enter Roll No:1
Enter marks of maths:12
Enter marks of science:4
Enter marks of Hindi:15

Enter Roll No:2
Enter marks of maths:13
Enter marks of science:2
Enter marks of Hindi:12

********Roll No and TOTAL Marks*********
Roll No Total Marks
12.04.0
13.02.0


********Highest marks in each subject with RollNo*******
Roll No2get highest marks in Subject1 i.e13.0
Roll No1get highest marks in Subject 2 i.e4.0

Roll No1get highest marks in Subject 3 i.e15.0

*****************Student Obtained Highest Marks**********
Roll No1get highest Marks

aidez moi svp