#ifndef __FINAL_IMPL_H
#define __FINAL_IMPL_H
#include
using namespace std;
/*
* General note: None of these functions should have ANY screen input or
* output!
*
* If you run the provided test main function, and any line starting with
* FIXME shows up it means that you have an error in your function.
*/
/*
* returns YOUR testnumber. Please no input or output!
*/
string testNumber();
/*
* division
* divides a by b (a/b). Makes sure, floating point division is used.
* If b is 0 this throws a C++-string exception "Division by Zero"
* (please use this exact string and do not catch the exception inside this
* function!
*/
double floatingPointDivision(int a, int b);
/*
* c00l f0ntz
* Some people think its cool to use 0's instead of o's and z's instead of s's.
* Help them by providing a function that will replace every o (both upper and
* lowercase) with 0 (the number zero) and all occurences of s with the letter
* z (s->z, S->Z). Provide both a C-string and a C++-string version.
* Please note: the function name itself contains the number zero.
*/
void c00lf0ntz(char *s);
void c00lf0ntz(string &s);
/*
* interest: If you deposited a penny in the bank in 0 A.D at an interest rate
* of 1%, how much money would you have now?
* Answer: 4.4 million.
* Answer: None, you would be dead
* Answer: None. No bank existed for 2000 years.
* However, in this function should handle such cases:
* Input:
* money: Amount in $ deposited
* interest: Interest rate in %
* years: Years of interest collected
* returns:
* money in bank after n years of interest
*/
double interest(double money, double interest, int years);
/*
* simple math.
* This function uses an enum to describe what operation to do.
* add: add a and b (a+b)
* subtract: subtract b from a (a-b)
* multiply: multiply a and b (a*b)
* and returns the result.
*/
enum operation { add, subtract, multiply };
int simpleMath(int a, int b, operation o);
/*
* Average: return the (integer division) average of some of the integers
* stored in a.
* first (inclusive) Index is start
* last (inclusive) index is a+(count-1)
* when count is less than 1 the average should be 0 (not a program crash)
*/
int average(int a[], int start, int count);
/*
* distance
* This function uses the struct point. It returns the distance between
* two points on a coordinate system:
* sqrt( (x2-x1)*(x2-x1) + (y2-y1)*(y2-y1) )
*/
struct point {
double x;
double y;
};
double dist(point a, point b);
/*
* count negatives: Counts the number of negative data values in a linked list
* this function should return the number of data values that are stored in a
* linked list. the linked list structure is the same as it has neem used in
* all class examples. If should work (return 0) if head points to NULL
*/
struct node
{
int data;
node *next;
};
int countNegatives(node *head);
/*
* Bonus question (not needed to get 100): This function returns the answer to
* the ultimate question for live, the universe and everything
*/
int deepThought();
#endif