Question
LAB 5.6 Complete Program Step 1: Remove areas2.cpp from the project and add the summation.cpp program in your Lab5 folder to the project. This file
LAB 5.6 Complete Program
Step 1: Remove areas2.cpp from the project and add the summation.cpp program in your Lab5 folder to the project. This file contains just a program shell in which you will write the programming statements needed to complete the program described below. Here is a copy of the file.
1 // Lab 5 - summation.cpp 2 // This program displays a series of terms and computes its sum. 3 // PUT YOUR NAME HERE. 4 #include
Step 2: Design and implement the summation.cpp program so that it generates and prints the terms and the sum of the following series: 1/2 + 1/4 + 1/8 + 1/16 + 1/32 + 1/64
Sample Run:
1/2 + 1/4 + 1/8 + 1/16 + 1/32 + 1/64 = .984375
Step 3: Modify the program so that it generates and prints the terms and the sum of this series up through the nth term, where the user enters a value for n between 2 and 10.
For example, if the user enters 5, the program will display the terms and compute and print the summation of the following terms: 1/21 + 1/22 + 1/23 + 1/24 + 1/25
This will require the addition of much more program logic as well as some additional variables.
Sample Run:
This program sums the series 1/2^1+ 1/2^2+ 1/2^3+ . . . + 1/2^n
What should n be in the final term (2 - 10)? 5
1/2 + 1/4 + 1/8 + 1/16 + 1/32 = .96875
Step 4: Once your program is working correctly, add a bottom test loop to the program that asks the user if he or she wishes to compute another series, and which continues to iterate so long as the user enters y or Y. You will need additional program logic and a new variable to do this.
Step 5: Test your program with the following inputs before entering y to quit.:
5
6
8
10
If your program is working correctly, all the sums will be less than 1. If they are not, you have a logic error which you need to find and fix.
Step 6: If your professor asks you to do so, print the final, revised source code and the output created by the inputs shown in step 5.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started