HW0055
Math 2984 - Fall 2017
Intro to Mathematical Problem Solving


TASK: Convert the binary number ABCDEFGH into decimal.


COMMENT: We suppose that a binary number of up to 8 digits is given. Each digit has the value of 0 or 1. The "H" digit is the "ones" digit, or "least significant" digit.

Examples:

        ABCDEFGH   Simpler    Decimal

        00000001         1          1 = 1
        00000011        11          3 = 2 + 1
        00010111     10111         23 = 16 + 4 + 2 + 1
        10010000  10010000        144 = 128 + 16
      


INSTRUCTIONS:

        Use the MATLAB input() command to get values
        "a" "b", "c", "d", "e", "f", "g", "h" from the user:

          a = ?;
          b = ?;
          c = ?;
          d = ?;
          e = ?;
          f = ?;
          g = ?;
          h = ?;

        Use the name "n" for the variable that will hold the decimal value,
        and start it at 0:

          n = 0;

        To figure out the actual value of n, we think as follows:

          "If h is a 1, then we add a 1 to n;"
          "If g is a 1, then we add a 2 to n;"
          "If f is a 1, then we add a 4 to n;"
          and so on.

        The first logical statement can be written this way:

          if ( h == 1 )
            n = n + 1;
          end

        To do the entire calculation, you need to add the steps to
        handle the other digits as well.

        After processing all 8 digits, print the value with this crazy statement:

          fprintf ( ' The value of %d%d%d%d%d%d%d%d is %d\n', a, b, c, d, e, f, g, h, n );
      


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

        % hw00055.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.