Question
Lab 03 - Newton's Method v1.1 Lab 03 - Newton's Method v1.1 Assignment Content Introduction This lab is intended to demonstrate your understanding of simple
Lab 03 - Newton's Method v1.1Lab 03 - Newton's Method v1.1Assignment Content
- Introduction
This lab is intended to demonstrate your understanding of simple Selection Statements, as well as validation of user input. We start with a description of a program and you will design and implement that program.
- Instructions and Requirements
1.) Create a new project calledLab 3 - Newton V1.1
2.) Rename the source code file to beLab3.cpp
3.) Open the previous ( Newton V1.0 ) source file and copy it's source code
4.) Paste the code from the Newton V1.0 project intoLab3.cpp, replacing the code that was there.
5.) Close the Version 1.0 code (So you don't modify it on accident )
6.) Make sure you have a heading like this
- /* Newton - Calculates the square root of a number with Newton's Method. Author: YourName Version: 1.1 */
7.) Locate the area in the code where you collected the user's input for S.
8.) Directly after it put code that does the following:
- Check to see if the user entered a negative number. If they did, print the error message
- "This program does not deal in complex numbers."
- If the user entered a positive number that was not between 20 and 400 (inclusive), then print the message
- "Number out of range [20-400]."
- If the user entered a valid number, then allow the algorithm to calculate and print out all the variables, just as you did in the previous lab.
- Expected Output
The next section shows results of a three successful runs, and represents the output of a correctly functioning program.
You may use this as test data to ensure that your program is functioning, if you wish, but do not use these values
for your submission.
- Run 1 - The user entered a negative number, and the program quit.
- Enter an integer, S: -25 This program does not deal in complex numbers.
- Run 2 - The user entered a number that wasn't within [20, 400], and the program quit.
- Enter an integer, S: 987654 Number out of range [20-400].
- Run 3 - The user entered a number in range, and the program printed the results.
- Enter an integer, S: 25 S = 25 x0 = 12.5000 x1 = 7.2500 x2 = 5.3491 x3 = 5.0113 x4 = 5.0000 x5 = 5.0000 x6 = 5.0000 x7 = 5.0000 x8 = 5.0000 x9 = 5.0000
- Going Further
You are not graded on this, but if you want to play around you can try some things.
1.) Include theiomanippackage and print the output in fixed notation to 4 places past the decimal.
2.) Move the declarations of the x0 through x9 variables to the branch where the user enters the correct numbers to ensure that memory is only allocated when absolutely needed.
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