Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Student {
- private String name;
- private Integer rollNumber;
- private int m1;
- private int m2;
- private int m3;
- private int totMarks;
- //Getter setter
- }
- public class StudentData {
- public static void main(String[] args) {
- Scanner sc = new Scanner(System.in);
- System.out.println("Enetr the number of Student");
- int totalStudent = sc.nextInt();
- Map<Integer,Student> map = new TreeMap<Integer,Student>();
- for(int i =0;i<totalStudent;i++) {
- Student ss = new Student();
- System.out.println("Enter the Student roll number");
- ss.setRollNumber(sc.nextInt());
- System.out.println("Enter the Student Name");
- ss.setName(sc.next());
- System.out.println("Enter the m1 marks ");
- ss.setM1(sc.nextInt());
- System.out.println("Enetr the m2 marks ");
- ss.setM2(sc.nextInt());
- System.out.println("Enter the m3 marks ");
- ss.setM3(sc.nextInt());
- ss.setTotMarks(ss.getM1()+ss.getM2()+ss.getM3());
- map.put(ss.getTotMarks(),ss);
- ss=null;
- }
- //stdList.forEach(System.out::print);
- for(Map.Entry<Integer,Student> m :map.entrySet()) {
- System.out.println(m);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement