HW012
Math 2984 - Fall 2017
Intro to Mathematical Problem Solving


TASK: Rewrite a positive number in scientific notation, using two WHILE statements.


COMMENT: A positive number x can be written in scientific notation as x = m * 10^e, where 1.0 ≤ m < 10 and e is an integer.

Examples:

        2017     =   2.017    * 10^3
        10       =   1.0      * 10^1
        3.14159  =   3.14159  * 10^0
        1        =   1.0      * 10^0
        0.000123 =   1.23     * 10^(-4)
      


INSTRUCTIONS:

        Use MATLAB's input() statement to request a positive number "x";

        Initialize "m" to x, and "e" to 0.  

        It is already now true that x = m * 10^e.  

        If  1 ≤ m < 10, then we have already reached scientific notation,
        and there's nothing more to so.

        AS LONG AS m is greater than 10, we need to divide m by 10 and
        increase e by 1.

        AS LONG AS m is less than 1, we need to multiply m by 10
        and decrease e by 1.

        Once you have got past your two WHILE loops, print the value of x,
        of m, of e, and of m * 10^e:

          fprintf ( 'x = %g = %f * 10^%d = %g\n', x, m, e, m * 10^e );
      


CHECK: To check your work, make sure that:

        x = 0.0001234 -> m = 1.234, e = -4
        x = 1.234     -> m = 1.234, e = 0
        x = 123.4     -> m = 1.234, e = 2
      


SUBMIT: Your work should be stored in a script file called "hw012.m". Your script file should begin with at least three comment lines:

        % hw012.m
        % YOUR NAME
        % This script (describe what it does)
        % Add any comments here that you care to make.
      
If this problem is part of an assignment, then submit it to Canvas.