You are on page 1of 3

Computing As Level Practical 4

Practical 4 Deadline 16 May 2011 in Class


Where can I find the Notes
https://docs.google.com/leaf?id=0B0FcVokPQXtUNmEyYzM3ZGItZjZhNC00NTFkLWI2OTUtY2ZlNmMwNTYxYj U2&hl=en

Goal

Become familiar with: Designing User Defined Functions Switch statement

Practical Hand-In
Make sure your practical is saved on the designated computer before leaving the class on the 16th of May 2011. If you need help with this ask your teacher before class starts. Remember to save your practical like this: NamePrac4.c (Example GertjiePrac4.c)

The Task
You are an independent software developer; you were contracted by Alma Mater Akademie to develop a calculator for the primary school. Your software will assist students in understanding basic mathematic concepts. Your calculator will be called Alma Mathics. Alma Mater already have the rights to a certain program called Prac4startupFile.c, this file can be found on the same page as your notes. (See link above) Use this program to help you get your calculator started. You will have to create the following functions: 1. displayMenu() 2. standardCalculator() 3. statsCalculator() 4. otherCalculator() Your main() function is already complete, main() calls displayMenu(), which in turn calls the other functions and is therefore called the driving function. displayMenu( )
This function will have 4 options a) Standard Calculator b) Stats Calculator c) Logic Calculator x) Exit Calculator

Standard Calculator
This function performs basic operations such as add, subtract, divide, multiply and exponention. This calculator wont take any input , but will return a double type value. The calling function (displayMenu) will then display the returned value with only two decimal values.

Author Francois Buys

Page 1

Computing As Level Practical 4


Stats Calculator
This function takes three parameter values, 2 double values and 1 char. The char will determine what operation was requested. < for Minimum value and > for Maximum value. The result of the query should then be return and formatted to 2 decimal places by the calling function.

Logic Calculator
This function has 1 integer type value in its parameter list. The function evaluates the input and returns 0 if the input is even and 1 if the input is odd. The calling function should then display : Value is odd/even depending on the returned value. (Even means value is dividable by 2)

Prac4StartupFile.c is shown below


#include <stdio.h> #include <math.h> //Function Prototypes void displayMenu(); double StandardCalculator(); double StatsCalculator(double, double, char); int OtherCalculator(int); //Main Function - DO NOT CHANGE MAIN!!! int main() { displayMenu(); return 0; } void displayMenu() { //Complete } double StandardCalculator() { //Complete } double StatsCalculator(double number1, double number2, char operation) { //Complete } int OtherCalculator(int n1) { //Complete }

Author Francois Buys

Page 2

Computing As Level Practical 4

Refer to the below figure for help on the appropriate output

Author Francois Buys

Page 3

You might also like