In this java program explain every line of this code. Thank you Source Code: import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner in = new Scanner(System.in); System.out.println("The function is f(x)= 2x+3(2)"); System.out.println("Width is 0.05"); System.out.print("Enter Lower Limit: "); double lowLim = in.nextFloat(); System.out.print("Enter Upper Limit: "); double upperLim = in.nextFloat(); double iterations = (upperLim - lowLim) / 0.05;
In this java program explain every line of this code. Thank you
Source Code:
import java.util.Scanner;
public class Main
{
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
System.out.println("The function is f(x)= 2x+3(2)");
System.out.println("Width is 0.05");
System.out.print("Enter Lower Limit: ");
double lowLim = in.nextFloat();
System.out.print("Enter Upper Limit: ");
double upperLim = in.nextFloat();
double iterations = (upperLim - lowLim) / 0.05;
int i = 0;
double finAns = 0;
while(i < iterations){
System.out.print("____________________________________________________________________________________________________________________________________");
System.out.print("\nIteration:" + (i + 1));
System.out.print("\nFunction\t|\tLower Limit \t|\t Upper Limit \t|\t LRAM Application (width=0.05) \t|\t Answer");
double initAns=((2*lowLim)+(3*2))*0.05;
System.out.printf("\nf(x)= 2x+3(2) \t\t| x=%.2f\t|\tx=%.2f\t |", lowLim,lowLim+0.05);
System.out.printf("\t f(x) = (2(%.2f)+3(2) * 0.05\t |\t %.2f\n",lowLim,initAns);
finAns += initAns;
lowLim+=0.05;
i += 1;
}
System.out.println("____________________________________________________________________________________________________________________________________");
System.out.println("Final answer/Summation of all iterations is:" + finAns);
}
}
..
See the picture below that's a output of this program.
Thank you
Step by step
Solved in 2 steps