Name: ____________________________________________________ Alpha: ________________________

Describe help received: _____________________________________________________________________

Print this homework sheet, bring it to the class, and turn it in right before the next lecture starts.

  1. [100pts] Write a program hw.cpp that works like this (user input colored in red):

    ~/$ ./hw
    B0100 + B1000 = 
    12
    
    ~/$ ./hw
    B0100 + D16 = 
    20
    
    ~/$ ./hw
    D1 + D3 = 
    4
    
    ~/$ ./hw
    D1 = 
    1
    

    In other words, the program takes a command in one of the two forms given below:

    
    number + number =
    
    
    or
    
    number = 
    
    

    Here, number is binary or decimal. In particular,

    Note: assume that the input is always formatted correctly, following the above rules.

    As shown in the above sample executions, the program calculates the input equation and prints the output number. Submit

    ~/bin/submit -c=IC210 -p=hw07B hw.cpp
    
    Turn in a printout of this cover sheet and the codeprint of hw.cpp