homework7 - Benjamin Jones 2/22/08 Final Report Laboratory...

Info iconThis preview shows pages 1–4. Sign up to view the full content.

View Full Document Right Arrow Icon
Benjamin Jones 2/22/08 Final Report Laboratory 7 Header File: // *********************************************************************** // File: functions.h // // Author: Benjamin Jones // Created: 21 February 2008 // Updated: Original // // Assignment: Lab 7 // Compiler: gcc version 4.1.1 // // ************************************************************************ // // Function Organization: // // I. Get necessary input from user (getInput) // I.A Get number to take roots of (must be 0<x<=100) // I.A.1 Read input // I.A.2 Validate input, if not valid // I.A.2.i Exit program // I.B Get the amount of precision (positive) // I.B.1 Read input // I.B.2 Validate input, if not valid // I.B.2.i Exit program //
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
// II. Setup plot parameters (plotRootGraph) // II.A Set number to root as maximum Y value // II.B Initialize max values for axises // II.B.1 Max X is constant value 10 // II.B.2 Max Y is the number to root // II.C Begin main plot sequence // II.C.1 Initialize percentage count, and y-axis values. // II.C.2 Print the header of format: // "Plot of the first 10 roots of <numberToRoot>" // II.C.3 While percentage is less than 100 begin loop // II.C.3.i Set old y value equal to new y value // II.C.3.ii New y value equals the current percentage // (as a decimal) multiplied by max y value rounded up // II.C.3.iii New r value (difference) equals max y minus new y // new y value // II.C.3.iv If the percentage divides into 1 evenly (scaling y) // II.C.3.iv.a Then display the following: // "<new R>|" // II.C.3.iv.b Begin plotting root points: // (plotRootLines) // II.C.3.v Otherwise display the following: // "<nothingHere>|" // II.C.3.v.a Begin plotting root points: // (plotRootLines) // II.C.3.vi Increment percentage by 1 (preference, arbitrary) // II.D Plot the x-axis (plotXAxis) // // III. Begin plotting root points (plotRootLines) // III.A While nthRoot is less than 10 begin loop // III.A.1 Find the nthRoot (findNthRoot) of the max y value // (round up)
Background image of page 2
// III.A.2 If result is equal to max y value and less than old y // III.A.2.i Then print '*' and spacing // III.A.3 Otherwise print some spacing // IV.A.4 Increment nthRoot by 1 // // IV. Calculate the nth root of the number to a given precision (findNthRoot) // IV.A Set the current value equal to the number to root over the root // IV.B Intialize the new value, as well as the difference comparison // IV.C If nth root is zero (no need to compute) // IV.C.1 Exit function returning the nth root // IV.D While the abolute value of the difference of the current value // and the new value is greater than the desired precision // IV.D.1 If new value is not zero (not the first time through // the loop) // IV.D.1.i Set current value equal to old value // IV.D.2 Set new value equal to the reciprocal of the root we // we are taking multiplied by the quantity of the // current value multiplied by the nth root minus one
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 4
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 16

homework7 - Benjamin Jones 2/22/08 Final Report Laboratory...

This preview shows document pages 1 - 4. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online