convert into c++ program

C++ for Engineers and Scientists
4th Edition
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Bronson, Gary J.
Chapter5: Repetition Statements
Section5.5: A Closer Look: Loop Programming Techniques
Problem 12E: (Program) Write a program that tests the effectiveness of the rand() library function. Start by...
icon
Related questions
Topic Video
Question

In this python program convert into c++ program. Thank you

Source Code:

print("The function is f(x)= 2x+3(2)")
print("Width is 0.05")
lowLim=float(input("Enter Lower Limit: "))
upperLim=float(input("Enter Upper Limit: "))
iterations = (upperLim - lowLim)/0.05
i=0
finAns = 0
while(i<iterations):
    print("_________________________________________________________________________________________________________________________________")
    print("Iteration:",(i + 1))
    print("Function\t\t|\tLower Limit \t|\t Upper Limit \t|\t LRAM Application (width=0.05) \t|\t Answer")
    initAns=((2*lowLim)+(3*2))*0.05
    print("f(x)= 2x+3(2) \t\t|\tx={:0.2f}\t\t|\tx={:0.2f}\t\t|\t f(x) = (2({:0.2f})+3(2) * 0.05\t|\t  {:0.2f}".format(lowLim,lowLim+0.05,lowLim,initAns))
    finAns += initAns
    lowLim+=0.05
    i += 1
print("_________________________________________________________________________________________________________________________________")
print("Final answer/Summation of all iterations is:",finAns)

 

..

See the picture below that's a output sample output of this program

Upper Limit
x=1.35
|Answer
Function
T
T
LRAM Application (width=0.05)
f(x) = (2(1.30)+3(2) * 0.05
Lower Limit
f(x)= 2x+3(2)
X=1.30
0.43
Iteration: 8
! Upper Limit
x=1.40
Function
Lower Limit
| x=1.35
LRAM Application (width=0.05) |
f(x) = (2(1.35)+3(2) * 0.05
Answer
f(x)= 2x+3(2)
0.44
Iteration: 9
! Upper Limit
x=1.45
|
LRAM Application (width=0.05) |
Function
Lower Limit
Answer
0.44
f(x)= 2x+3(2)
x=1.40
f(x) = (2(1.40)+3(2)
ө.05
Iteration: 10
Upper Limit
x-1.50
LRAM Application (width=0.e5) I
f(x) = (2(1.45)+3(2) * 0.05
Function
Lower Limit
Answer
f(x)- 2х+3(2)
X=1.45
0.45
Iteration: 11
I Lower Limit
x=1.50
|
Upper Limit
x=1.55
LRAM Application (width=0.05) |
f(x) = (2(1.50)+3(2) * 0.05
Function
Answer
f(x)= 2x+3(2)
0.45
Iteration: 12
I LRAM Application (width=e.05) |
f(x) = (2(1.55)+3(2)
Function
Lower Limit
! Upper Limit
Answer
0.46
f(x)= 2x+3(2)
x=1.55
x=1.60
0.05
Iteration: 13
Lower Limit
| x=1.60
Upper Limit
x=1.65
LRAM Application (width=0.e5) |
f(x) = (2(1.60)+3(2) * 0.05
Function
Answer
f(x)= 2x+3(2)
ө.46
Iteration: 14
Upper Limit
x=1.70
| LRAM Application (width=0.e5) |
f(x) = (2(1.65)+3(2) * 0.05
Function
Lower Limit
Answer
f(x)= 2x+3(2)
x=1.65
0.47
Iteration: 15
Function
LRAM Application (width=0.05) I
f(x) = (2(1.70)+3(2) * 0.05
Lower Limit
Upper Limit
Answer
f(x)= 2x+3(2)
x=1.70
x=1.75
0.47
Iteration: 16
Function
f(x)= 2x+3(2)
Lower Limit
Upper Limit
x=1.80
LRAM Application (width=0.e5) I
F(x) = (2(1.75)+3(2) * 0.05
Answer
x=1.75
0.48
Iteration: 17
Function
Upper Limit
x-1.85
| LRAM Application (width=0.e5) |
f(x) = (2(1.8e)+3(2) • 0.05
Lower Limit
Answer
f(x)= 2x+3(2)
X=1.80
0.48
Iteration: 18
Function
Lower Limit
Upper Limit
LRAM Application (width=0.05) |
Answer
0.49
f(x)= 2x+3(2)
x=1.85
x=1.90
F(x) = (2(1.85)+3(2) * 0.05
Iteration: 19
Function
f(x)= 2x+3(2)
! Upper Limit
X=1.95
LRAM Application (width=0.05) |
f(x) = (2(1.90)+3(2)
Lower Limit
Answer
x=1.90
0.49
Iteration: 20
LRAM Application (width=0.05) |
f(x) = (2(1.95)+3(2) * 0.05
Function
Lower Limit
Upper Limit
Answer
f(x)= 2x+3(2)
| x=1.95
x=2.00
0.50
Final answer/Summation of all iterations is: 8.95
--
Transcribed Image Text:Upper Limit x=1.35 |Answer Function T T LRAM Application (width=0.05) f(x) = (2(1.30)+3(2) * 0.05 Lower Limit f(x)= 2x+3(2) X=1.30 0.43 Iteration: 8 ! Upper Limit x=1.40 Function Lower Limit | x=1.35 LRAM Application (width=0.05) | f(x) = (2(1.35)+3(2) * 0.05 Answer f(x)= 2x+3(2) 0.44 Iteration: 9 ! Upper Limit x=1.45 | LRAM Application (width=0.05) | Function Lower Limit Answer 0.44 f(x)= 2x+3(2) x=1.40 f(x) = (2(1.40)+3(2) ө.05 Iteration: 10 Upper Limit x-1.50 LRAM Application (width=0.e5) I f(x) = (2(1.45)+3(2) * 0.05 Function Lower Limit Answer f(x)- 2х+3(2) X=1.45 0.45 Iteration: 11 I Lower Limit x=1.50 | Upper Limit x=1.55 LRAM Application (width=0.05) | f(x) = (2(1.50)+3(2) * 0.05 Function Answer f(x)= 2x+3(2) 0.45 Iteration: 12 I LRAM Application (width=e.05) | f(x) = (2(1.55)+3(2) Function Lower Limit ! Upper Limit Answer 0.46 f(x)= 2x+3(2) x=1.55 x=1.60 0.05 Iteration: 13 Lower Limit | x=1.60 Upper Limit x=1.65 LRAM Application (width=0.e5) | f(x) = (2(1.60)+3(2) * 0.05 Function Answer f(x)= 2x+3(2) ө.46 Iteration: 14 Upper Limit x=1.70 | LRAM Application (width=0.e5) | f(x) = (2(1.65)+3(2) * 0.05 Function Lower Limit Answer f(x)= 2x+3(2) x=1.65 0.47 Iteration: 15 Function LRAM Application (width=0.05) I f(x) = (2(1.70)+3(2) * 0.05 Lower Limit Upper Limit Answer f(x)= 2x+3(2) x=1.70 x=1.75 0.47 Iteration: 16 Function f(x)= 2x+3(2) Lower Limit Upper Limit x=1.80 LRAM Application (width=0.e5) I F(x) = (2(1.75)+3(2) * 0.05 Answer x=1.75 0.48 Iteration: 17 Function Upper Limit x-1.85 | LRAM Application (width=0.e5) | f(x) = (2(1.8e)+3(2) • 0.05 Lower Limit Answer f(x)= 2x+3(2) X=1.80 0.48 Iteration: 18 Function Lower Limit Upper Limit LRAM Application (width=0.05) | Answer 0.49 f(x)= 2x+3(2) x=1.85 x=1.90 F(x) = (2(1.85)+3(2) * 0.05 Iteration: 19 Function f(x)= 2x+3(2) ! Upper Limit X=1.95 LRAM Application (width=0.05) | f(x) = (2(1.90)+3(2) Lower Limit Answer x=1.90 0.49 Iteration: 20 LRAM Application (width=0.05) | f(x) = (2(1.95)+3(2) * 0.05 Function Lower Limit Upper Limit Answer f(x)= 2x+3(2) | x=1.95 x=2.00 0.50 Final answer/Summation of all iterations is: 8.95 --
The function is f(x)= 2x+3(2)
Width is 0.05
Enter Lower Limit: 1
Enter Upper Limit: 2
Iteration: 1
Function
f(x)= 2x+3(2)
! Upper Limit
x=1.05
Lower Limit
LRAM Application (width=0.05)
f(x) = (2(1.00)+3(2)
Answer
0.40
x=1.00
* 0.05
Iteration: 2
Lower Limit
x=1.05
|
LRAM Application (width=0.e5) |
f(x) = (2(1.e5)+3(2) • 0.05
Function
Upper Limit
Answer
f(x)= 2x+3(2)
X=1.10
0.41
Iteration: 3
LRAM Application (width=0.05)
f(x) = (2(1.10)+3(2) * 0.05
Function
Lower Limit
Upper Limit
Answer
f(x)= 2x+3(2)
X=1.10
x=1.15
0.41
Iteration: 4
Lower Limit
I x=1.15
LRAM Application (width=0.05) |
f(x) = (2(1.15)+3(2) * 0.05
Function
Upper Limit
Answer
f(x)= 2x+3(2)
x=1.20
0.42
Iteration: 5
Upper Limit
LRAM Application (width=0.05) |
f(x) = (2(1.20)+3(2) * 0.05
Function
Lower Limit
Answer
f(x)= 2x+3(2)
x=1.20
x=1.25
0.42
Iteration: 6
Function
f(x)= 2x+3(2)
LRAM Application (width=0.05) I
f(x) = (2(1.25)+3(2) * 0.05
Lower Limit
Upper Limit
x=1.30
Answer
X=1.25
0.43
Iteration: 7
Function
f(x)= 2x+3(2)
Lower Limit
x=1.30
Upper Limit
x=1.35
LRAM Application (width=0.05) |
F(x) = (2(1.30)+3(2) * 0.05
Answer
0.43
Iteration: 8
Function
f(x)= 2x+3(2)
Upper Limit
I LRAM Application (width=e.05) |
f(x) = (2(1.35)+3(2) * 0.05
Lower Limit
!
x=1.40
Answer
x=1.35
0.44
Iteration: 9
Function
f(x)= 2x+3(2)
Upper Limit
x=1.45
LRAM Application (width=0.05) |
f(x) = (2(1.40)+3(2) * 0.05
Lower Limit
Answer
x=1.40
0.44
Iteration: 10
Function
f(x)= 2x+3(2)
Upper Limit
x-1.50
LRAM Application (width=0.05) |
f(x) = (2(1.45)+3(2) * 0.05
Lower Limit
Answer
x=1.45
0.45
Iteration: 11
Lower Limit
| x=1.50
! Upper Limit
x=1.55
Function
|
LRAM Application (width=0.05) |
Answer
f(x)= 2x+3(2)
f(x) = (2(1.50)+3(2) * 0.05 I
0.45
Iteration: 12
Function
f(x)= 2x+3(2)
LRAM Application (width=0.05) |
f(x) = (2(1.55)+3(2) * 0.05
Lower Limit
Upper Limit
Answer
x=1.55
X=1.60
ө.46
Iteration: 13
Function
f(x)= 2x+3(2)
LRAM Application (width=0.05) |
f(x) = (2(1.60)+3(2) * 0.05
Lower Limit
! Upper Limit
Answer
x=1.60
x=1.65
0.46
----. 14
Transcribed Image Text:The function is f(x)= 2x+3(2) Width is 0.05 Enter Lower Limit: 1 Enter Upper Limit: 2 Iteration: 1 Function f(x)= 2x+3(2) ! Upper Limit x=1.05 Lower Limit LRAM Application (width=0.05) f(x) = (2(1.00)+3(2) Answer 0.40 x=1.00 * 0.05 Iteration: 2 Lower Limit x=1.05 | LRAM Application (width=0.e5) | f(x) = (2(1.e5)+3(2) • 0.05 Function Upper Limit Answer f(x)= 2x+3(2) X=1.10 0.41 Iteration: 3 LRAM Application (width=0.05) f(x) = (2(1.10)+3(2) * 0.05 Function Lower Limit Upper Limit Answer f(x)= 2x+3(2) X=1.10 x=1.15 0.41 Iteration: 4 Lower Limit I x=1.15 LRAM Application (width=0.05) | f(x) = (2(1.15)+3(2) * 0.05 Function Upper Limit Answer f(x)= 2x+3(2) x=1.20 0.42 Iteration: 5 Upper Limit LRAM Application (width=0.05) | f(x) = (2(1.20)+3(2) * 0.05 Function Lower Limit Answer f(x)= 2x+3(2) x=1.20 x=1.25 0.42 Iteration: 6 Function f(x)= 2x+3(2) LRAM Application (width=0.05) I f(x) = (2(1.25)+3(2) * 0.05 Lower Limit Upper Limit x=1.30 Answer X=1.25 0.43 Iteration: 7 Function f(x)= 2x+3(2) Lower Limit x=1.30 Upper Limit x=1.35 LRAM Application (width=0.05) | F(x) = (2(1.30)+3(2) * 0.05 Answer 0.43 Iteration: 8 Function f(x)= 2x+3(2) Upper Limit I LRAM Application (width=e.05) | f(x) = (2(1.35)+3(2) * 0.05 Lower Limit ! x=1.40 Answer x=1.35 0.44 Iteration: 9 Function f(x)= 2x+3(2) Upper Limit x=1.45 LRAM Application (width=0.05) | f(x) = (2(1.40)+3(2) * 0.05 Lower Limit Answer x=1.40 0.44 Iteration: 10 Function f(x)= 2x+3(2) Upper Limit x-1.50 LRAM Application (width=0.05) | f(x) = (2(1.45)+3(2) * 0.05 Lower Limit Answer x=1.45 0.45 Iteration: 11 Lower Limit | x=1.50 ! Upper Limit x=1.55 Function | LRAM Application (width=0.05) | Answer f(x)= 2x+3(2) f(x) = (2(1.50)+3(2) * 0.05 I 0.45 Iteration: 12 Function f(x)= 2x+3(2) LRAM Application (width=0.05) | f(x) = (2(1.55)+3(2) * 0.05 Lower Limit Upper Limit Answer x=1.55 X=1.60 ө.46 Iteration: 13 Function f(x)= 2x+3(2) LRAM Application (width=0.05) | f(x) = (2(1.60)+3(2) * 0.05 Lower Limit ! Upper Limit Answer x=1.60 x=1.65 0.46 ----. 14
Expert Solution
steps

Step by step

Solved in 3 steps with 3 images

Blurred answer
Knowledge Booster
Instruction Format
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr