Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 60 additions & 10 deletions assignemntOne.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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;
Expand All @@ -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();

Copy link
Copy Markdown
Owner

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 ?

int[] arr=new int[6];
int max1=arr[0];
for(int i=0;i<8;i++){

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The 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++){

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The 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())

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The 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());
}
}
}