Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Complete java program by adding method swapMark() Java program implementation Complete the following java program by adding a method swap Mark() to swap two reference
Complete java program by adding method swapMark()
Java program implementation Complete the following java program by adding a method swap Mark() to swap two reference variables. The two student marks must be swapped by the method. Please do not delete the existing code. The tests will be executed automatically. For example: Test Student s1 = new Student (50); Student s2 = new Student (100); Course course = new Course(); course.swapMark(s1, s2); course.displayMark (s1, s2); Student s1 = new Student (50); Student s2 = new Student (100); Course course = new Course(); course.swapMark(s1, s2); course.swapMark(s1, s2); course.displayMark (s1, s2); Result std1 mark: 100.0, std2 mark: 50.0 std1 mark: 50.0, std2 mark: 100.0 Answer: (penalty regime: 0 %) Reset answer 1 class Student{ private double mark; public Student (double m) { mark=m; public double getMark() { return mark; public void setMark (double newMark) { mark=newMark; 2 3 4 5 6 } 7 8 9 10 11 12- 13 14 15 16 25 26 PENNY222222222222 27 } } } } } 17 class Course{ public void swap Mark (Student s1, Student s2) { //add your code here 18 19-> 20 21 } 23 24 public void displayMark (Student s1, Student s2){ System.out.println("std1 mark: "+s1.getMark()+", std2 mark: "+s2.getMark());
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started