I have this lab report quistion I would like help to answer first here is the dr
ID: 3671937 • Letter: I
Question
I have this lab report quistion I would like help to answer
first here is the driver class which the instircter doesn't want me to edit
Then here is my code to solve a numerical integration for x^2
my code works perfect but I have to answer those quistions
1- Why does the solution you wrote work for a generic function?
2- Why does the Calculus class not need a constructor?
3- How can I tell in the Driver class that integrate() is a static method?
import java.util.Scanner: public class Driver public static void main (String[] args) Scanner in - new Scanner (System.in); System.out.println ("What is the lower bound? >" double lowerBound = in.nextDouble(); System.out.println("What is the upper bound? >" double upperBound = in.nextDouble(); out.printin(What is the upper bound? >) System.out.println("How many rectangles would you like to use? ") int numRec = in . nextInt(); double area Calculus . integrate(lowerBound, upperBound, numRec); = System.out.println("-" System.out. format ("Approximate area= %.6f ", area); System.out.println ("Explanation / Answer
1.A generic method can have one or more type parameters. Note that when a generic method is used,there is no explicit mention of the type that is substituted for the type parameter. The compiler deduces the type from the types of the actual parameters in the method call.
2.Calculus class does not need a constructor beacause it does not want to create object of it automatically.
3.integrate() is static method since its type of input parameters are fixed i.e two double and one integer.