Project #1: Multi-base calculator

Submit: Turn in your basecalc.c source file using the turnin command on morbius.mscsnet.mu.edu or one of the other Systems Lab machines.

Work is to be completed individually. Be certain to include your name in the file. You may submit multiple times, but only the last turnin will be kept. The automatic submission system will not accept work after the deadline. (See turnin instructional video HERE. Note that the video is for a different course number, and that Morbius's domain name has changed since the video was made: morbius.mscs.mu.edu -> morbius.mscsnet.mu.edu)

Include a comment block at the very top of each file that contains the following:

/**
 * COSC 3250 - Project 1
 * Explain briefly the functionality of the program.
 * @author [your name]
 * Instructor [your instructor]
 * TA-BOT:MAILTO [your email address]
 */

All Your Base Are Belong To Us*

Write a calculator program that reads in expressions consisting of integers and the operators +, -, *, /, %, ^ (exponentiation), & (bitwise AND), | (bitwise OR), << (left shift), and >> (right shift), and prints the results when evaluated in simple left-to-right order.

Your calculator should understand positive integers in binary, octal, decimal, and hexadecimal, but all results will be decimal (base-10) integers. Binary operands will begin with "0b", followed by a string of 0s and 1s; operands in all other bases will follow the traditional C language notation.

You should use the getchar library function to read console input one character at a time. The use of any other library functions for input is not recommended at this time.

We have provided an example program for your reference, executable on Morbius as ~brylow/os/Projects/basecalc.

Notes

* - Early Internet meme reference, circa 2001, (en.wikipedia.org/wiki/All_your_base_are_belong_to_us)


[back]

[Revised 2020 Aug 26 00:10 DWB]