Writing a program for midterm

While trying to do the program on the midterm, i decided to code it on
the computer to make sure that it worked.