-
Notifications
You must be signed in to change notification settings - Fork 9
assignmentOne is modified #2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,9 +6,22 @@ class Student{ | |
|
|
||
| int usn; | ||
| char sem; | ||
| int marks[] = new int[8]; | ||
| <TO DO:Add Constructor to initialize sem and usn> | ||
| <TO DO : Add constructor with no intializations> | ||
| int marks[] = new int[6]; | ||
|
|
||
| // <TO DO:Add Constructor to initialize sem and usn> | ||
|
|
||
| Student(int usn,char sem){ | ||
| this.usn=usn; | ||
| this.sem=sem; | ||
| } | ||
|
|
||
| // <TO DO : Add constructor with no intializations> | ||
|
|
||
| Student(){ | ||
| int usn=this.usn; | ||
| int sem=this.sem; | ||
| } | ||
|
|
||
| public void setSem() { | ||
| Scanner sc = new Scanner(System.in); | ||
| this.sem=sc.next().charAt(0); | ||
|
|
@@ -19,7 +32,15 @@ public void setUsn(int usn) { | |
|
|
||
| } | ||
|
|
||
| <TO DO : ADD METHOD TO SET MARKS> | ||
| // <TO DO : ADD METHOD TO SET MARKS> | ||
|
|
||
| public void marks(){ | ||
| Scanner sc=new Scanner(System.in); | ||
| int[] arr=new int[6]; | ||
| for(int i=0;i<6;i++){ | ||
| arr[i]=sc.nextInt(); | ||
| } | ||
| } | ||
|
|
||
| public int[] getMarks() { | ||
| return marks; | ||
|
|
@@ -43,14 +64,43 @@ public static void main(String[] args) { | |
| int usn; | ||
| int sem; | ||
| Student eeeStudent2 = new Student(usn,sem); | ||
| <TO DO: Assign marks to students> | ||
|
|
||
| <TO DO: Print the max marks of both students> | ||
|
|
||
| <TO DO: Take input of a subject index from user and print | ||
| which student has more marks in that subject> | ||
|
|
||
|
|
||
| // <TO DO: Assign marks to students> | ||
|
|
||
| eeeStudent1.marks(); | ||
| eeeStudent2.marks(); | ||
|
|
||
| // <TO DO: Print the max marks of both students> | ||
| eeeStudent1.marks(); | ||
| int[] arr=new int[6]; | ||
| int max1=arr[0]; | ||
| for(int i=0;i<8;i++){ | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Create a method inside the class |
||
| if(arr[i]>max1) | ||
| max1=arr[i]; | ||
| } | ||
| System.out.println(max1); | ||
|
|
||
| eeeStudent2.marks(); | ||
| int max2=arr[0]; | ||
| for(int i=0;i<8;i++){ | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Create a method inside the class to find max marks |
||
| if(arr[i]>max2) | ||
| max2=arr[i]; | ||
| } | ||
| System.out.println(max2); | ||
|
|
||
| // <TO DO: Take input of a subject index from user and print | ||
| // which student has more marks in that subject> | ||
|
|
||
| char[] sub=new char[6]; | ||
| Scanner sc = new Scanner(System.in); | ||
| char index = sc.next().charAt(0); | ||
| if(index==char[i]){ | ||
| if(eeeStudent1.marks() > eeeStudent2.marks()) | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. isnt marks the method to set the marks? Why is it being called here ? |
||
| System.out.println("maxm marks in that sub is:"+eeeStudent1.marks()); | ||
| else | ||
| System.out.println(eeeStudent2.marks()); | ||
| } | ||
| } | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the need for this call ?