Question: Suppose that we have the two classes below. Trace the execution of the main program in the Course class using a memory diagram public class

Suppose that we have the two classes below. Trace the execution of the main program in the Course class using a memory diagram

public class Student

{

private String name;

private int exam1;

private int exam2;

public Student(String name, int exam1, int exam2)

{

this.name = name;

this.exam1 = exam1;

this.exam2 = exam2;

}

public char findGrade()

{

double avg = getAverage();

if (avg >=90.0)

return 'A';

else if (avg >= 80.0)

return 'B';

else if (avg >= 70.0)

return 'C';

else if (avg >= 40.0)

return 'D';

else

return 'F';

}

public String getName()

{

return this.name;

}

public double getAverage()

{

return (exam1 + exam2)/2.0;

}

public void setExam1(int exam1)

{

this.exam1 = exam1;

}

public void setExam2(int exam2)

{

this.exam2= exam2;

}

}

import java.util.ArrayList;

public class Course

{

public static void main(String[] args)

{

Student first = new Student("Fred Flintstone", 83, 74);

Student second = new Student ("Barney Rubble", 60, 93);

Student third = new Student("Wilma Flintstone", 86, 92);

ArrayList students = new ArrayList();

students.add(first);

 Suppose that we have the two classes below. Trace the execution

of the main program in the Course class using a memory diagram

students.add(second);

students.add(third);

Student change = students.get(0);

change.setExam1(80);

}

}

2. 15 points) Suppose that we have the two classes below. Trace the execution of the main program in the Course class using a memory diagram public class Student private String name; private iat examl; private iat exam2; public student(string name, exan1 , exa 2) this.naename; this eraiexami; public char findacada double as e: if (a -9e.e) return 'A else if - 88.8) return else if (xe>- 78.8) return C else if (axe, >- 48.8) return D else return F public String getNaae return this.nane; public double getAec return (exanexan2)/2.8 public void setExaml(iot exani) public void setExa 2(40 exa 2) this exa exam2; 2. 15 points) Suppose that we have the two classes below. Trace the execution of the main program in the Course class using a memory diagram public class Student private String name; private iat examl; private iat exam2; public student(string name, exan1 , exa 2) this.naename; this eraiexami; public char findacada double as e: if (a -9e.e) return 'A else if - 88.8) return else if (xe>- 78.8) return C else if (axe, >- 48.8) return D else return F public String getNaae return this.nane; public double getAec return (exanexan2)/2.8 public void setExaml(iot exani) public void setExa 2(40 exa 2) this exa exam2

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!