CMIS 102 Week 7 Hands On Lab
Just Click on Below Link To Download This Course:
http://bit.ly/3aTPEMC
CMIS 102 Week 7 Hands On Lab
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 two
user-defined function.
Program
Description
This program will provide options for a user to calculate the square or cube of
a positive Integer input by a user. The program will prompt the user to enter
an Integer and then prompt the user if they want to
calculate the square of the cube of the number. Based on the inputs of the
user, the program will output
the square of the cube of the positive integer. The program will then print the
Integer and square or cube of the integer based on the user’s original choice.
The program will continue to prompt the user for
Integers and their calculation choice until the user enters a negative integer.
The square and cube calculations should be calculated using a function.
Analysis
I will use sequential, selection, and repetition programming statements and
functions for the cube and
square calculations. I will define three Integer numbers: IntValue, MenuSelect,
Results to store the Integer value input by the user, the Menu selection (1 for
Square, 2 for Cube) of the user, and the results of the Square or Cube
functions.
The Square
function will take one Integer as input and return one Integer as the output.
The calculation within the Square function is: Results = IntValue * IntValue
For example: if 10 was entered as the IntValue. Results = 10*10 = 100
The Cube
function will take one Integer as input and return one Integer as the output.
The calculation
within the Cube function is: Results = IntValue * IntValue*IntValue
For example: if 10 was entered as the IntValue. Results = 10*10*10 = 1000
A repetition loop can be used to loop through iterations
until a negative is entered:
|
1 2 3 |
|
Test
Plan
To verify this program is working properly the input values could be used for
testing:
|
Test
Case |
Input |
Expected
Output |
|
1 |
IntValue=10 |
Square of 10 is 100 |
|
2 |
IntValue=10 |
Cube of 10 is 1000 |
|
3 |
IntValue=-1 |
Program exits |
Pseudocode
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
|
C
Code
The following is the C Code that will compile in execute in the online
compilers.
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
|
Setting up the code and the input parameters in
ideone.com:
Note the
Input values for this run were:
10
5
1
10
2
-99
You can
change these values to any valid integer values to match your test cases.
6
Learning
Exercises for you to complete
- Using the Square and Cube functions as models, Create an
application that includes a function named “Shrink” that would take an
Integer and return the Integer divided by 2? (Hint: your returned value
should probably be a double type.) Support your experimentation with
screen captures of executing the new code.
- Prepare a new test table with at least 3 distinct test cases
listing input and expected output for the code you created after step 1.
- What would happen if you removed the following code from our
design? If intValue > 0 Support your argument with screen captures of
executing the new code.
- Modify the original code and add an additional
function of your choice. The function should be unique and something you
created for this assignment. Support your experimentation with screen
captures of executing the new code. Prepare a test table with at least 3
distinct test cases listing input and expected output for your unique
function.


Comments
Post a Comment