diff --git a/assignemntOne.java b/assignemntOne.java index c5cb392..5e4e35f 100644 --- a/assignemntOne.java +++ b/assignemntOne.java @@ -6,9 +6,17 @@ class Student{ int usn; char sem; - int marks[] = new int[8]; + int marks[] = new int[10]; + Student(int usn,char sem){ + this.usn = usn; + this.sem = sem; + } + + Student(){ + } + public void setSem() { Scanner sc = new Scanner(System.in); this.sem=sc.next().charAt(0); @@ -20,6 +28,10 @@ public void setUsn(int usn) { } + + public setMarks(int []marks){ + this.marks = marks; +} public int[] getMarks() { return marks; @@ -32,25 +44,47 @@ public char getSem() { public int getUsn() { return usn; } + + + public int max_Marks{ + int temp=0; + for(int x:marks){ + if(x>temp){ + temp=x; + } + } + return temp; + } } public class assignemntOne { public static void main(String[] args) { + Scanner input = new Scanner(System.in); Student eeeStudent1 = new Student(); - int usn; - int sem; + int usn = 91; + char sem = 'V'; Student eeeStudent2 = new Student(usn,sem); + int []marks1 = new int[10]; + int []marks2 = new int[10]; + for(int i=0;i<10;i++){ + marks1[i] = input.nextInt(); + } + eeeStudent1.setMarks(marks1); + + marks2[]={23,34,12,13,56,89,90,76,30.10}; + eeesStudent2.setMarks(marks2); + System.out.println("Maximum marks of student 1 and 2 are "+eeeStudent1.max_Marks,eeeStudent2.max_Marks); - - - } + int index = input.nextInt(); + char max = (eeeStudent1.marks[index]>eeeStudent2.marks[index]) ? '1':'2'; + System.out.println("Student"+max+" has secured highest marks in subject "+index); }