When running JavaApplication8, the following output is seen on the display:
Addition(2,3) = 5
JavaApplication.java is given below with some missing parts in the Circuit class and printCircuit method (missing parts are identified by dots):
class Circuit{
private String operation;
private int number1, number2, output;
public Circuit(int n1, int n2){ …}
public void setNumbers(int n1, int n2){ …}
public void setOperation(…){operation=op;}
public void setN1(int n){number1 = n;}
public void setN2(int n){number2 = n;}
public void setOutput(int n){… = n;}
public … getOperation(){return operation;}
public … getN1(){return number1;}
public int getN2(){…}
public int getOutput(){return output;}
}
public class JavaApplication8 {
private static void printCircuit(Circuit a) { … }
public static void main(String[] args) {
Circuit a1 = new Circuit(2,3);
a1.setOperation("Addition");
a1.setOutput(a1.getN1()+a1.getN2());
printCircuit(a1);
}
}
1. Fill in all missing parts
2. Modify the main() method so that the output becomes:
Subtraction(2,3) = -1