+ Students are not permitted to use input/output statements for questions 1 to 4. All input data must be passed via function arguments, and the output should return by arguments or return value.
+ Students can write additional functions for code convenience
Questions:
1. Write a function to calculate area of a triangle. (1.5 marks)
Hint: Formula for triangle area: S=p(pa) (pb)(pc) with p=(a+b+c)/2. a,b,c are 3 sides of triangle. The function should return -1 for invalid triangle.
2. Write a function that calculates the total year-end bonus each employee receives based on their sales under the following conditions: if your annual sales are below $100,000, you will only receive a year-end bonus of $1,000. If your sales are between $100,000 and $120,000, you will receive 1% of the amount exceeding $100,000. If your sales are between $120,000 and $140,000, you will receive 2% of the amount exceeding $120,000. If your sales exceed $140,000,
you will receive 3% of the amount exceeding $140,000.(2 marks).
3. Write a function to calculate S according to the following formula (n > 0): (2 marks)
S=1!2!3!1+V1+1+2+√1+√2+1+2+3+√1+√2 + √3+**+n!1+2+n+v1+√2 + √3+...+ √n
4. Write a function that returns a list of even elements and sorts them in ascending order from an unsorted array of integers (1.5 marks)
5. Write main() function to invoke the 4 functions above:
+ Offertext menu for user choice to execute the functions. (1 mark)
+ For each choice, demonstration of successfully running the selected function (0.5 mark for each).
Note:
1. Students are only allowed to use DevC++ software and offline documents (on personal
+ 100%
Zoom
Close