Question
These are the instructions that my professor gave us for the assignment: Write a C++ program to compute the value of PI based upon the
These are the instructions that my professor gave us for the assignment:
Write a C++ program to compute the value of PI based upon the Gregory-Leibniz Series given the number in the series.
2. Accept the sequence number from the user (as an integer). (5 points) 3. Do not allow the program to continue until the sequence number selected by the user is positive (at least 1). (5 points). 4. Compute and print the value of PI using the Gregory-Leibniz Series up to the sequence number entered by the user (35 points)
Sample Runs:
Welcome to the compute PI program... What is the sequence number?-9 What is the sequence number? (must be an integer > 0)0 What is the sequence number? (must be an integer > 0)-6 What is the sequence number? (must be an integer > 0)30000 3.141559320256469190054890439078860708832508
Welcome to the compute PI program... What is the sequence number?65 3.156976358911272252617472022784284035878954
Welcome to the compute PI program... What is the sequence number?1000000 3.14159165358979318525417534502253147365991
I set up the code and have gotten all of it right except that when I run my program, the answer doesn't show as much decimal places as my professor's sample runs do. For example, when I input the sequence number as 65, my answer is 3.14156 not the full answer my professor has. I tried using showpoint << setprecision (seqnum) but it didn't work. Help?
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