69 679
Assignments Done
Successfully Done
In February 2019

Answer to Question #63574 in Java | JSP | JSF for scott

Question #63574
1.Create a class called Divider in this project.

2.Declare a private instance variable of type int called divisor, then write a line of code in the constructor to initialise divisor to 2.

3. Write a public getter method for divisor.

4. Write a public setter method for divisor, which sets divisor to the value of the argument, provided the latter is not 0. If it is 0, the method does nothing. (This is because, as its name suggests, divisor is going to be used to divide, so the argument’s value cannot be zero, and the setter must only set it to non-zero values.)

Show an instance of the class to be used in testing, like..

something = something
Expert's answer
public class Divider {
public int divisor;
public Divider() {
public int getDivisor() {
return divisor;
public void setDivisor(int divisor) {
if(divisor != 0) {
this.divisor = divisor;
public class DividerTest {
public static void main(String[] args) {
Divider d1 = new Divider();
System.out.println("Divisor = " + d1.getDivisor());
System.out.println("Divisor = " + d1.getDivisor());
System.out.println("Divisor = " + d1.getDivisor());

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!


No comments. Be first!

Leave a comment

Ask Your question

Privacy policy Terms and Conditions