UMBC CMSC 104 CSEE | 104 | current 104

CMSC104, Spring 2009

Programming Project 3

Math Helper v0.1

Out: Monday, April 27, 2009
Due Date: Monday, May 11, 2009 before 11:59pm


The Objective

This project is designed to give you practice with loops (for/while), switch statements and characters, as well as functions.

The Task

The local elementary school has asked you to volunteer as a helper in several of its classrooms. You have come to realize that the students need the most help with math (go figure!) There are few problems that you find yourself helping with frequently, so you have decided to create some software that will assist you. Your software is going to allow the user to print a multiplication table, find the greatest common divisor of two numbers and raise a number to a particular power.

The Details

For this project, since it is your first using functions, I am providing you with the function prototypes needed. You must use the following function prototypes EXACTLY. You may not change them in any way. However, you may use additional functions if you wish. Your software should initially present a menu to the user. The menu should have four options. Each option will perform a different task. The options are as follows:

Additional Information


Sample Output

linux3[92]% gcc -ansi -Wall proj3.c
linux3[93]% ls
a.out  proj3.c
linux3[94]% a.out

Welcome to Math Helper v0.1!

Your greeting goes here. It should contain a very
detailed explantion of the program.

M - Print a Multiplication Table
G - Find the Greatest Common Divisor
R - Raise a Number to a Power
Q - Quit

Enter your menu selection: M

Enter the maximum multiplier/multiplicand you would
like to see in the multiplication table: 8


Multiplication Table with a maximum multiplier/multiplicand of 8:

       1   2   3   4   5   6   7   8
    --------------------------------
 1 |   1   2   3   4   5   6   7   8
 2 |   2   4   6   8  10  12  14  16
 3 |   3   6   9  12  15  18  21  24
 4 |   4   8  12  16  20  24  28  32
 5 |   5  10  15  20  25  30  35  40
 6 |   6  12  18  24  30  36  42  48
 7 |   7  14  21  28  35  42  49  56
 8 |   8  16  24  32  40  48  56  64


M - Print a Multiplication Table
G - Find the Greatest Common Divisor
R - Raise a Number to a Power
Q - Quit

Enter your menu selection: m

Enter the maximum multiplier/multiplicand you would
like to see in the multiplication table: 4


Multiplication Table with a maximum multiplier/multiplicand of 4:

       1   2   3   4
    ----------------
 1 |   1   2   3   4
 2 |   2   4   6   8
 3 |   3   6   9  12
 4 |   4   8  12  16


M - Print a Multiplication Table
G - Find the Greatest Common Divisor
R - Raise a Number to a Power
Q - Quit

Enter your menu selection: G

Enter the first integer: 35
Enter the second integer: 20

The greatest common divisor of 35 and 20 is 5.

M - Print a Multiplication Table
G - Find the Greatest Common Divisor
R - Raise a Number to a Power
Q - Quit

Enter your menu selection: G

Enter the first integer: 31
Enter the second integer: 19

The greatest common divisor of 31 and 19 is 1.

M - Print a Multiplication Table
G - Find the Greatest Common Divisor
R - Raise a Number to a Power
Q - Quit

Enter your menu selection: r

Enter the base number: 4
Enter the power: 2

4 raised to the power 2 is 16.

M - Print a Multiplication Table
G - Find the Greatest Common Divisor
R - Raise a Number to a Power
Q - Quit

Enter your menu selection: R

Enter the base number: 5
Enter the power: 3

5 raised to the power 3 is 125.

M - Print a Multiplication Table
G - Find the Greatest Common Divisor
R - Raise a Number to a Power
Q - Quit

Enter your menu selection: T
T is not a valid menu choice.

M - Print a Multiplication Table
G - Find the Greatest Common Divisor
R - Raise a Number to a Power
Q - Quit

Enter your menu selection: y
Y is not a valid menu choice.

M - Print a Multiplication Table
G - Find the Greatest Common Divisor
R - Raise a Number to a Power
Q - Quit

Enter your menu selection: Q

Thank you for using Math Helper v0.1.

linux3[95]%


Submitting the Program

Here is a sample submission command. Note that the project name starts with uppercase 'P'.

submit cs104_101 Proj3 proj3.c

To verify that your project was submitted, you can execute the following command at the Unix prompt. It will show the file that you submitted in a format similar to the Unix 'ls' command.

submitls cs104_101 Proj3