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

Create a Circuit class that uses three data members to store the resistance, inp

ID: 3614857 • Letter: C

Question

Create a Circuit class that uses three data members to store the resistance, input voltage, and current of a circuit. The Circuit class also has the following member functions: A constructor with arguments to initialize data members A function that computes and returns current (input voltage divided by resistance) A function that displays values of resistance, input voltage and current Create an Amplifier class that inherits all members from Circuit except constructor (cannot be inherited). In addition to the inherited members, the Amplifier class has some specific members: A data member gain A constructor with arguments to initialize data members A function that computes and returns an output voltage (input voltage multiplied by gai n) a function that returns gai n Design the main() function to instantiate an object of the Amplifier class and than use this object to call all member functions.

Explanation / Answer

import java.io.*; import java.lang.*; import java.util.*; class Circuit{ public float resistance; public float voltage; public float current; public Circuit( float resistance, float voltage, float current) {    this.resistance = resistance;    this.voltage = voltage;    this.current = current; } public float computeCurrent() {    this.current = (voltage / resistance);    return current; } public void display() {    System.out.println("======================================");    System.out.println("The voltage of this circuitis: " + this.voltage);       System.out.println("The resistance of thiscircuit is: " + this.resistance);    System.out.println("The current of this circuitis: " + this.current);    System.out.println("======================================"); } } public class Amplifier extends Circuit{ public float gain; public Amplifier(float resistance, float voltage, float current,float gain) {    super(resistance, voltage, current);    this.gain = gain;    } public float computeOutputVoltage() {    return ((this.voltage) * (this.gain)); } public float gain() {    return this.gain; } public static void main(String[] args){    Amplifier a = new Amplifier(10, 100, 10, 2);    a.computeCurrent();    a.display();    System.out.println("The gain is: " +a.gain());    System.out.println("The output Voltage is: "+a.computeOutputVoltage()); } }