[SOLVED] CMIS102-Lab7- Functions

30.00 $

Programming resource
Digital learning resource
Category:
✓ Practical programming resource
✓ Suitable for guided study and reference
✓ Tutor guidance available when needed

Description

5/5 - (1 vote)

Week 7
Overview This hands-on lab allows you to follow and experiment with the critical steps of developing a program including the program description, analysis, test plan, design, and implementation with C code. The example provided uses sequential, repetition, selection statements and user-defined functions.
Program Description
Write a program that will allow the user to select from a variety of mathematical functions, evaluate that function at a numerical value, and keep going until the user enters a selection indicating that the user is done with the program.
The program should be written in such a way that adding new functions to the source code is relatively easy.
Interaction
A menu will be presented to the user as a prompt. The exact menu will depend upon the actual functions currently available in the program. Here is one typical interaction, where a, b, c, etc. represent function selections.
>Make a selection: a: a(x) = x*x b: b(x) = x*x*x c: c(x) = x^2 + 2*x + 7 q: quit Enter selection and value, or q: a 3.45 c(3.45) = 3.45^2 + 2*3.45 + 7 = 25.80 Analysis
1. Use float data types for input, calculations and results. 2. Create a main input loop to select a function or quit. 3. Create a good prompt, including a list of possible selections to help the user. 4. Include appropriate printf functions within the math functions. 5. Make the main method simple by using a while loop, and a menu function which will return a special number if the user chooses the quit option. a. while (menu () == 0); b. if the menu function returns a 0 then continue c. returning any other value will end the program. 6. Use the ^ symbol in the display to indicate a power of x, i.e., x^4 means x*x*x*x. 7. Write a simple message when the program is over, such as “… bye …”.

Resource details

Understand the Task Before You Use the Resource

Review the requirements, identify the programming concepts involved, study the implementation and test your understanding with your own examples and modifications.