Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

  1. 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.

  1. 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

  1. /* 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.

  1. 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.

  1. Run 1 - The user entered a negative number, and the program quit.

  1. Enter an integer, S: -25 This program does not deal in complex numbers.

  1. Run 2 - The user entered a number that wasn't within [20, 400], and the program quit.

  1. Enter an integer, S: 987654 Number out of range [20-400].

  1. Run 3 - The user entered a number in range, and the program printed the results.

  1. 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

  1. 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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Mobile Communications

Authors: Jochen Schiller

2nd edition

978-0321123817, 321123816, 978-8131724262

More Books

Students also viewed these Programming questions

Question

Socially responsible marketing communication (pp. 424425)

Answered: 1 week ago