In this java program fixed this code because there is an error. After you fixed the code please run the program and show the output of this code. Thank you.

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

In this java program fixed this code because there is an error. After you fixed the code please run the program and show the output of this code. Thank you.

Source Code:

// Online Java Compiler
// Use this editor to write, compile and run your Java code online
import java.lang.*;
import java.util.*;
class HelloWorld {
    float ln(int x, int y){
        lnX = Math.log(x);
        lnY = Math.log(y);
        ln = lnX + lnY;
        return ln;
        
    }
    public static void main(String[] args) {
        System.out.println("Enter lower limit:-");
        Scanner sc= new Scanner(System.in);
        int lower = sc.nextInt();
         System.out.println("Enter higher limit:-");
        int higher = sc.nextInt();
        int iterations  = (higher -1)/0.05;
        float y = 1.05;
        float final_answer = 0;
        for(int i=0;i<iterations;i++){
            float  ans = ln(lower, y);
            lower += 0.05;
            y = lower + 0.05;
            final_answer += ans;
            int x = Math.round(lower,2);
            x = Math.round(x,2);
            y = math.round(y,2);
            System.out.println("_________________________________________________________________________________________________________________");
            System.out.println("Iteration:"+Math.round(x,2));
            System.out.println("Function\\|\Lower Limit \|\ Upper Limit \|\ Trapezoid Application (width=0.05) \|");
            System.out.println("(ln(x)+ln(x)/2)1 \|\x="+Math.round(x,2)+"\|\x="+Math.round(y,2),"\|\ (ln("+x+")+ln("+y+")/2)1\|\\Answer: "+ans);
            
        }
            System.out.println("_________________________________________________________________________________________________________________");
            System.out.println("\\Total Iterations:"+Math.round(x,2));
            System.out.println("Final Answer/Summation of all iterations:"+final_answer)
    }
}

 

See the picture below that's an sample output of the program.

IDLE Shell 3.10.0
Eile
Edit
Shell
Debug
Options
Window
Help
RESTART:
D:/Program Files
(x86) /python/2.py
=====
Enter
lower limit:
Enter upper
limit:
Iterat ion:
Functi on
(In (x) +ln (x) /2)1
1.05
Trapezoid Application
(In (
Lower Limit
Upper Limit
(width=0.05)
1.05
x= 1.10
1.05
) +ln ( 1.10 )/2)1
x=
Answer:
O.0975 8032833886408
Iterat ion:
1.10
Trapezoid Application
(In ( 1.10 )+ln ( 1.15 )/2)1
Function
Lower Limit
Upper Limit
(width=0.05)
(ln (x) ++ln (x) /2)1
x= 1.10
x= 1.15
Answer:
0.23941052377 808192
Iterat ion:
1.15
Trapezoid Application
(in ( 1.15 ) +ln ( 1.20 )/2)1
Function
Lower Limit
Upper Limit
(width=o.05)
(in (x) +ln (x)/2)1
x= 1.15
x= 1.20
Answer:
0.3748340645546422
Iteration: 1.20
Trapezoid Application
(in ( 1.20 ) +ln ( 1.25 )/2) 1
Function
Lower Limit
Upper Limit
(width= o.05)
(in (x) +ln (x)/2)1
x= 1.20
x= 1.25
Answer:
0.504405055963068
Iterat ion:
1.25
Trapezoid Application
(In ( 1.25
Function
Lower Limit
Upper Limit
(width=o.05)
(in (x) +ln (x) /2)1
1.25
1.30
) +ln ( 1.30 )/2)1
Answer:
0.6286086594223743
Iterat ion:
Functi on
(in (x) +ln (x) /2)1
1.30
Trapezoid Application
(ln ( 1. 30 ) +ln ( 1.35 )/2)1
Lower Limit
Upper Limit
(width=o.05)
x= 1.30
x= 1.35
Answer:
0.747872080249192
Iteration:
1.35
Functi on
(in (x) +ln (x) /2)1
Trapezoid Application
(in (
Lower Limit
Upper Limit
(width=o.05)
x= 1.35
1.40
1.35 ) +ln (
1.40
)/2)1
Ln: 492
Col: 0
IDLE Shell 3.10.0
Edit
Iterat ion:
Functi on
(in (x) +ln (x) /2)1
File
Shell
Debug
Options
Window
Help
1.35
Trapezoid Application
(in ( 1.35 ) +ln ( 1.40 )/2)1
Lower Limit
Upper Limit
(width=o.05)
x= 1.35
x= 1.40
Answer:
0.8625734493681676
Iterat ion:
1.40
Trapezo id Application
(in ( 1. 40 ) +ln ( 1.45 )/2)1
Function
Lower Limit
Upper Limit
(width=o.05)
(In (x) +ln (x)/2)1
1.40
x= 1.45
Answer:
0.9730490656927642
Iterat ion:
1.45
Trapezoid Application
(in ( 1.45 ) +1n ( 1.50 )/2)1
Function
Lower Limit
Upper Limit
(width=o.05)
(In (x) +ln (x) /2)1
x= 1.45
x= 1.50
Answer :
1.079599349486179
Iterat ion:
1.50
Trapezoid Application
(In ( 1. 50 ) +ln ( 1.55 )/2)1
Function
Lower Limit
Upper Limit
(width= o.05)
(in (x) +ln (x)/2)1
x= 1.50
X= 1.55
Answer:
1.182493772648812
Iterat ion:
1.55
Trapezoid Application
(In ( 1.55 ) +ln ( 1.60 )/2)1
Function
Lower Limit
Upper Limit
(width=o.05)
(in (x) +ln (x)/2)1
1.55
x= 1.60
Answer:
1.2819749699704752
Iterat ion:
Functi on
(in (x) +ln (x) /2) 1
1.60
Trapezoid Application
(In ( 1.60 ) +ln ( 1.65 )/2)1
Lower Limit
Upper Limit
(width= o.05)
1.60
x= 1.65
Answer:
1.3782621894226268
Iteration:
1.65
Trapezoid Application
(In ( 1. 65 ) +ln ( 1.70 )/2) 1
Function
Lower Limit
Upper Limit
(width=o.05)
(In (x) +ln (x)/2)1
1.65
x= 1.70
Answer:
1.4715542050707142
Iterat ion:
Functi on
1.70
Lower
Limit
Upper Limit
Trapezoid Application
(width=o.05)
Ln: 492
Col: 0
IDLE Shell 3.10.0
File
Edit
Shell
Debug Options
Window
Help
Answer:
1.4715542050707142
Iteration: 1.70
Function
Lower L imit
Upper Limit
Trapezoid Application
(width=0.05)
(In (x) +ln (x)/2) 1
x= 1.70
x= 1.75
(In ( 1.70 )+1n ( 1.75 )/2) 1
Answer:
1.5620317900368303
Iteration: 1.75
Function
Lower Limit
Upper Limit
Trapezoid Application (width-0.05)
(In (x) +ln (x)/2) 1
x= 1.75
x= 1.80
(In ( 1.75 )+ln ( 1.80 )/2) 1
Answer:
1.649859826933016
Iteration: 1.80
Function
Lower Limit
Upper Limit
Trapezoid Application (width=0.05)
(In (x) +ln (x) /2)1
1.80
x= 1.85
(In ( 1.8O )+1n ( 1.85 )/2)1
Answer:
1.7351891177396612
Iteration:
1.85
Function
Lower Limit
Upper Limit
Trapezoid Application (width=0.05)
(In (x) +ln (x) /2) l
x= 1.85
x= 1.9O
(In ( 1.85 ) +ln ( 1.90 )/2)1
Answer:
1.8181579430825865
Iteration:
1.90
Function
Lower Limit
Upper Limit
Trapezoid Application
(width=0.05)
(In (x) +ln (x)/2) 1
x= 1.90
x= 1.95
(ln ( 1.90 ) +ln ( 1.95 )/2) 1
Answer:
1.898893411435023
Iteration:
1.95
Trapezoid Application
(In ( 1.95 )+1n ( 2.00 )/2)1
Function
Lower Limit
Upper Limit
(width-0.05)
(In (x) +ln (x) /2) 1
1.95
x= 2.0O
Answer:
1.9775126313237061
Total Iterations:
1.95
Final Answer/Summation of all iterations:
21.46386243451678
>>>
Ln: 492
Col: 0
Transcribed Image Text:IDLE Shell 3.10.0 Eile Edit Shell Debug Options Window Help RESTART: D:/Program Files (x86) /python/2.py ===== Enter lower limit: Enter upper limit: Iterat ion: Functi on (In (x) +ln (x) /2)1 1.05 Trapezoid Application (In ( Lower Limit Upper Limit (width=0.05) 1.05 x= 1.10 1.05 ) +ln ( 1.10 )/2)1 x= Answer: O.0975 8032833886408 Iterat ion: 1.10 Trapezoid Application (In ( 1.10 )+ln ( 1.15 )/2)1 Function Lower Limit Upper Limit (width=0.05) (ln (x) ++ln (x) /2)1 x= 1.10 x= 1.15 Answer: 0.23941052377 808192 Iterat ion: 1.15 Trapezoid Application (in ( 1.15 ) +ln ( 1.20 )/2)1 Function Lower Limit Upper Limit (width=o.05) (in (x) +ln (x)/2)1 x= 1.15 x= 1.20 Answer: 0.3748340645546422 Iteration: 1.20 Trapezoid Application (in ( 1.20 ) +ln ( 1.25 )/2) 1 Function Lower Limit Upper Limit (width= o.05) (in (x) +ln (x)/2)1 x= 1.20 x= 1.25 Answer: 0.504405055963068 Iterat ion: 1.25 Trapezoid Application (In ( 1.25 Function Lower Limit Upper Limit (width=o.05) (in (x) +ln (x) /2)1 1.25 1.30 ) +ln ( 1.30 )/2)1 Answer: 0.6286086594223743 Iterat ion: Functi on (in (x) +ln (x) /2)1 1.30 Trapezoid Application (ln ( 1. 30 ) +ln ( 1.35 )/2)1 Lower Limit Upper Limit (width=o.05) x= 1.30 x= 1.35 Answer: 0.747872080249192 Iteration: 1.35 Functi on (in (x) +ln (x) /2)1 Trapezoid Application (in ( Lower Limit Upper Limit (width=o.05) x= 1.35 1.40 1.35 ) +ln ( 1.40 )/2)1 Ln: 492 Col: 0 IDLE Shell 3.10.0 Edit Iterat ion: Functi on (in (x) +ln (x) /2)1 File Shell Debug Options Window Help 1.35 Trapezoid Application (in ( 1.35 ) +ln ( 1.40 )/2)1 Lower Limit Upper Limit (width=o.05) x= 1.35 x= 1.40 Answer: 0.8625734493681676 Iterat ion: 1.40 Trapezo id Application (in ( 1. 40 ) +ln ( 1.45 )/2)1 Function Lower Limit Upper Limit (width=o.05) (In (x) +ln (x)/2)1 1.40 x= 1.45 Answer: 0.9730490656927642 Iterat ion: 1.45 Trapezoid Application (in ( 1.45 ) +1n ( 1.50 )/2)1 Function Lower Limit Upper Limit (width=o.05) (In (x) +ln (x) /2)1 x= 1.45 x= 1.50 Answer : 1.079599349486179 Iterat ion: 1.50 Trapezoid Application (In ( 1. 50 ) +ln ( 1.55 )/2)1 Function Lower Limit Upper Limit (width= o.05) (in (x) +ln (x)/2)1 x= 1.50 X= 1.55 Answer: 1.182493772648812 Iterat ion: 1.55 Trapezoid Application (In ( 1.55 ) +ln ( 1.60 )/2)1 Function Lower Limit Upper Limit (width=o.05) (in (x) +ln (x)/2)1 1.55 x= 1.60 Answer: 1.2819749699704752 Iterat ion: Functi on (in (x) +ln (x) /2) 1 1.60 Trapezoid Application (In ( 1.60 ) +ln ( 1.65 )/2)1 Lower Limit Upper Limit (width= o.05) 1.60 x= 1.65 Answer: 1.3782621894226268 Iteration: 1.65 Trapezoid Application (In ( 1. 65 ) +ln ( 1.70 )/2) 1 Function Lower Limit Upper Limit (width=o.05) (In (x) +ln (x)/2)1 1.65 x= 1.70 Answer: 1.4715542050707142 Iterat ion: Functi on 1.70 Lower Limit Upper Limit Trapezoid Application (width=o.05) Ln: 492 Col: 0 IDLE Shell 3.10.0 File Edit Shell Debug Options Window Help Answer: 1.4715542050707142 Iteration: 1.70 Function Lower L imit Upper Limit Trapezoid Application (width=0.05) (In (x) +ln (x)/2) 1 x= 1.70 x= 1.75 (In ( 1.70 )+1n ( 1.75 )/2) 1 Answer: 1.5620317900368303 Iteration: 1.75 Function Lower Limit Upper Limit Trapezoid Application (width-0.05) (In (x) +ln (x)/2) 1 x= 1.75 x= 1.80 (In ( 1.75 )+ln ( 1.80 )/2) 1 Answer: 1.649859826933016 Iteration: 1.80 Function Lower Limit Upper Limit Trapezoid Application (width=0.05) (In (x) +ln (x) /2)1 1.80 x= 1.85 (In ( 1.8O )+1n ( 1.85 )/2)1 Answer: 1.7351891177396612 Iteration: 1.85 Function Lower Limit Upper Limit Trapezoid Application (width=0.05) (In (x) +ln (x) /2) l x= 1.85 x= 1.9O (In ( 1.85 ) +ln ( 1.90 )/2)1 Answer: 1.8181579430825865 Iteration: 1.90 Function Lower Limit Upper Limit Trapezoid Application (width=0.05) (In (x) +ln (x)/2) 1 x= 1.90 x= 1.95 (ln ( 1.90 ) +ln ( 1.95 )/2) 1 Answer: 1.898893411435023 Iteration: 1.95 Trapezoid Application (In ( 1.95 )+1n ( 2.00 )/2)1 Function Lower Limit Upper Limit (width-0.05) (In (x) +ln (x) /2) 1 1.95 x= 2.0O Answer: 1.9775126313237061 Total Iterations: 1.95 Final Answer/Summation of all iterations: 21.46386243451678 >>> Ln: 492 Col: 0
Expert Solution
steps

Step by step

Solved in 3 steps with 2 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY