SHARE
TWEET

Untitled

a guest Jun 16th, 2019 55 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. public class Student {
  2.     private String name;
  3.     private Integer rollNumber;
  4.     private int m1;
  5.     private int m2;
  6.     private int m3;
  7.     private int totMarks;
  8.     //Getter setter
  9. }
  10.      
  11. public class StudentData {
  12.     public static void main(String[] args) {
  13.         Scanner sc = new Scanner(System.in);
  14.         System.out.println("Enetr the number of Student");
  15.         int totalStudent = sc.nextInt();
  16.         Map<Integer,Student> map = new TreeMap<Integer,Student>();
  17.         for(int i =0;i<totalStudent;i++) {
  18.             Student ss = new Student();
  19.             System.out.println("Enter the Student roll number");
  20.             ss.setRollNumber(sc.nextInt());
  21.             System.out.println("Enter the Student Name");
  22.             ss.setName(sc.next());
  23.             System.out.println("Enter the m1 marks ");
  24.             ss.setM1(sc.nextInt());
  25.             System.out.println("Enetr the m2 marks ");
  26.             ss.setM2(sc.nextInt());
  27.             System.out.println("Enter the m3 marks ");
  28.             ss.setM3(sc.nextInt());
  29.             ss.setTotMarks(ss.getM1()+ss.getM2()+ss.getM3());
  30.  
  31.             map.put(ss.getTotMarks(),ss);
  32.             ss=null;
  33.         }  
  34.         //stdList.forEach(System.out::print);
  35.         for(Map.Entry<Integer,Student> m :map.entrySet()) {
  36.             System.out.println(m);
  37.         }
  38.  
  39.     }
  40. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top