Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Below is the outline of a simple class called BusyWork. In the blank space provi

ID: 3763255 • Letter: B

Question

Below is the outline of a simple class called BusyWork. In the blank space provided in the class, add two methods to the class. The two methods that you add can make use of the two given methods setNumber() and getNumber().

(a) Add a method increment() that adds 1 to the value of m.

(b) Add a method decrement() that returns a BusyWork object whose value of m is one less than the value stored in the calling object. This method should not modify the m in the object the method is called on.

class BusyWork

{ int m = 0;

public void setNumber(int newM)

{

this.m = newM;

}

public int getNumber()

{

return this.m;

} // write the methods increment() and decrement()

}//BusyWork

Explanation / Answer

public class Number
{

private int m ;
  
public void setName(int m)
{

m=n;
}


public String get m()
{
return m;
}


public static void incrementAndDecrement()
{

int m= 0;

for(int i = 10; i >= 0; i--)
{
System.out.println(i);
System.out.println(m);
m++;
}
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote