Introduction to Problem Solving and Algorithm Design
Using the above Code of Ethics, Pick at least 2 of the 8 principles and describe what these principles mean to you. In your write-up, summarize the principles you selected in your own words and provide at least one example of an activity or action you could take that would support each principle and one example of an activity or action that you believe would violate each principle. Be sure your document is well-written with minimal grammatical and spelling issues.
1. CMIS 102 Homework 1 Solution (100% Correct)
For more classes visit
www.snaptutorial.com
Introduction to Problem Solving and Algorithm Design
Using the above Code of Ethics, Pick at least 2 of the 8 principles and
describe what these principles mean to you. In your write-up, summarize
the principles you selected in your own words and provide at least one
example of an activity or action you could take that would support each
principle and one example of an activity or action that you believe
would violate each principle. Be sure your document is well-written with
minimal grammatical and spelling issues.
**********************************************************
CMIS 102 Homework 2 Test Case Creation
Using the following pseudocode (100% Correct)
For more classes visit
2. www.snaptutorial.com
Homework 2 – Test Case Creation Using the following pseudocode,
provide 3 unique test cases that would help validate your
algorithm. Be sure to place the test cases in a table showing the input
https://www.coursehero.com/tutors-problems/Computer-
Science/10754291-I-need-help-with-c-coding-asap-how-much-will-it-
be/zvalues, and expected output
for each test case.
Write "Enter the price in dollars:"
Input Price
Write "Enter state sales tax(e.g. .06) :"
Input SalesTax
Set Price = Price + (Price * SalesTax)
Write "Price with Tax is" + Price Submit your word or PDF
file to your assignments folder no later than the due date. Grading
guidelines
Submission
A minimum of 3 test cases were provided.
Input provided and explained for each test case.
Expected output provided and explained for each test case.
3. Test cases represent a wide variety of possible input values (e.g. large
numbers,
small numbers (0), negative, or unexpected non-number entries).
Total Points
2
1
1
1
5
**********************************************************
CMIS 102 Homework 3 (100% Correct)
For more classes visit
www.snaptutorial.com
Create your own unique While-End or (For End) repetition C code. You
decide the theme. Be sure to provide an overview of what your repetition
4. structure is doing. Please keep the design simple for this exercise. Just a
few lines of code is all that is needed for this response. This should be
code you wrote for an application that is interesting to you. In other
words, make it your own and have fun with it.
Provide the C code and a screen capture showing the results of testing
your code in an online compiler. Be sure to test your code with several
test cases and show your test case table
**********************************************************
CMIS 102 Homework 4 Create your own
Function
For more classes visit
www.snaptutorial.com
Create your own function in C that accepts one input parameter and
returns a float number. You decide the theme.
You should provide both your C code and an example call to the C code
function. Be sure to provide an overview of what your function is doing.
Provide a screen capture showing the results of testing your code in an
online compiler.
5. Be sure to test your code with several test cases and show your test case
table.
Submit your word or PDF file to your assignments folder no later than
the due date.
**********************************************************
CMIS 102 Week 1 Hands-On Lab
For more classes visit
www.snaptutorial.com
CMIS 102 Week 1 Hands-On Lab
This hands-on lab demonstrate a simple sequential print statements using
an online C compiler such as ideone.com. You should follow the
instructions to complete the lab as well as perform the learning exercises
at the end of this lab.
Instructions
1. Open up any online C compiler (e.g ideone.com).
2. Be sure the C Language is selected.
6. 3. Enter the code below into the editor. (Note: LEO doesn’t let you just
copy and paste from this document so you can either download the
document and then copy and paste or just go to the Code for HelloWorld
link for this week and copy and paste from there.)
4. Click the submit, or run button.
5. Try the additional learning exercises on the next page. Here is what
Hello, World! Looks like using ideone.com after it has successfully run
Hello, World C code
1
2
3
4
5
6 #include <stdio.h>
int main(void) {
printf("Hello, World!");
return 0;
}
Learning Exercises for you to complete
1. Remove the semi-colon (;) at the end of this statement:
1 printf("Hello, World!");
7. 2. Describe what happens. Why is the semi-colon needed?
3. What happens if you add another printf statement such as:
1 printf("Goodbye"); after the printf("Hello, World!"); line?
4. Describe the new output. Be sure to support your description with
screen captures of executing the new code.
5. Experiment by adding additional printf statements to your code such
as:
1
2 printf("Goodbye n");
printf("Hello, again! n");
6. What does the “n” do to the output?
**********************************************************
CMIS 102 Week 2 Hands-On Lab
For more classes visit
www.snaptutorial.com
CMIS 102 Week 2 Hands-On Lab
8. 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.
Program Description
This program will sum two integer numbers to yield a third integer
number. Once the calculations are made the results of all the numbers
will be printed to the output screen.
Analysis
We will use sequential programming statements.
We will define 3 integer numbers: a, b, c.
c will store the sum of a and b.
Test Plan
To understand this program the following input numbers could be used
for testing:
a = 10
b = 20
c = a + b = 10 + 20 = 30
In table format the following results are expected:
Learning Exercises for you to complete
1. Change the C code to calculate the product of two integers as opposed
to the sum of two integers. Support your experimentation with a screen
capture of executing the new code.
9. 2. Prepare a new test table with at least 3 distinct test cases listing input
and expected output for the product of two integers.
3. Change the C code to calculate the quotient (e.g. a/b) of two floats
(e.g. 2.3/1.5).Hint: Use float variable types as opposed to integers. What
happens if the denominator is 0.0? Support your experimentation with
screen captures of executing the new code
4. Prepare a new test table with at least 3 distinct test cases listing input
and expected output for
the quotient of two floats.
Submission
• Submit a neatly organized word (or PDF) document that demonstrates
you successfully executed this lab on your machine using an online
compiler. You should provide a screen capture of the resulting output.
• Also, provide the answers, associated screen captures, C Code and
descriptions of your successful completion of learning exercises 1, 2, 3
and 4.
• The answers to the learning exercises, screen captures, C code and
descriptions can be included in the
same neatly organized document you prepared as you ran this lab. Note
the code can be embedded in the word document. However; be sure all
code compiles and runs perfectly before submitting the document.
• Submit your document no later than the due date listed in the syllabus
or calendar.
10. **********************************************************
CMIS 102 Week 3 Hands-On Lab
For more classes visit
www.snaptutorial.com
CMIS 102 Week 3 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, pseudocode visualization, and implementation
with C code. The example provided uses mathematical operators and
variable types. Program
Description
This program will calculate the area of a right triangle. The program will
ask the user to enter the base and height and then use these values to
calculate and then print the area of the triangle. The design step will
include pseudocode.
Analysis
I will use sequential programming statements. I will define two float
numbers for the base and height: base, height. Float numbers were
11. selected as opposed to integers to make sure triangles of all dimensions
are possible and not just whole numbers.
Float number will store the area: area
The area will be calculated by this formula:
Area = ½ * (base * height)
For example if the base was 4.2 and the height was 5.3 the area would be
calculated as:
Area = ½ * (4.2 * 5.3) = ½ * (22.26) = 11.13
Test Plan
To verify this program is working properly the following base and
height values could be used for testing:
Learning Exercises to be complete (Setting up the code and the input
parameters in ideone.com:)
1. Change the C code to calculate the perimeter of a triangle. Support
your experimentation with a screen capture of executing the new code
2. Prepare a new test table with at least 3 distinct test cases listing input
and expected output for the perimeter of a triangle.
3. What is this line of code doing?
1 scanf("%f", &height);
4. How would you change this line if you wanted to input an Integer as
opposed to a float?
5. What are the values of f and g after executing the following C?
12. **********************************************************
CMIS 102 Week 4 Hands-On Lab
For more classes visit
www.snaptutorial.com
CMIS 102 Hands-On Lab
Week 4
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 (using
pseudocode), and implementation
with C code. The example provided uses sequential and selection
statements.
Program Description
This program will calculate the sum of 5 integers. The program will ask
the user to 5 integers. If the sum
13. of the numbers is greater than 100, a message is printed stating the sum
is over 100. The design step will
include both pseudocode.
Analysis
I will use sequential, and selection programming statements.
I will define six integer numbers: value1, value2, value3, value4, value5
and sum. The value1, value2,
value3, value4 and value5 variables will store the integers input by the
user. The sum will store the sum
of the 5 values.
The sum will be calculated by this formula:
sum = value1 + value2 + value3 + value4 + value5
For example, if the first values entered were value 1=1, value 2=1, value
3=2,value 4=2 and value 5=3
respectively:
sum = 1 + 1 + 2 + 2 + 3 = 9
The additional selection statement will be of this form:
If sum > 100 then
print "Sum is over 100"
End If Test Plan
To verify this program is working properly the input values could be
used for testing:
14. Test Case
1 2 Input
value1=1
value2=1
value3=1
value4=0
Value5=2
value=100
value=100
value=100
value=100
value=200 Expected Output
Sum = 5 Sum = 600
Sum is over 100. 1 3 value= -100
value= -100
value= -200
value = 0
value= 200 Sum = -200 Pseudocode
// This program will calculate the sum of 5 integers.
// Declare variables
Declare value1, value2, value3, value4, value5, sum as Integer
15. //Initialize Sum to 0
Set sum = 0
// Enter
Print
Input
Print
Input
Print
Input
Print
Input
Print
Input values
“Enter
value1
“Enter
value2
“Enter
value3
“Enter
value4
16. “Enter
value5 an Integer for value1”
an Integer for value2”
an Integer for value3”
an Integer for value4”
an Integer for value5” // Calculate sum
sum = value1 + value2 + value3 + value4 + value5
// Print results and messages
Print “Sum is “ + sum
If (sum > 100)
Printf “Sum is over 100”
End if C Code
The following is the C Code that will compile in execute in the online
compilers.
// C code
// This program will calculate the sum of 5 integers.
// Developer: Faculty CMIS102
// Date: Jan 31, XXXX
#include <stdio.h>
int main () 2 {
/* variable definition: */
17. int value1,value2,value3,value4,value5,sum; /* Initialize sum */
sum = 0;
printf("Enter an Integer
scanf("%d", &value1);
printf("Enter an Integer
scanf("%d", &value2);
printf("Enter an Integer
scanf("%d", &value3);
printf("Enter an Integer
scanf("%d", &value4);
printf("Enter an Integer
scanf("%d", &value5); for value1n");
for value2n");
for value3n");
for value4n");
for value5n"); sum = value1 + value2 + value3 + value4 + value5;
printf("Sum is %dn " , sum );
if (sum >100)
printf("Sum is over 100n");
return 0;
} Setting up the code and the input parameters in ideone.com:
18. Note the input integer values are 100, 100, 100, 200 and 100, for this test
case. You can change these
values to any valid integer values to match your test cases. 3 Results
from running within ideone 4 Learning Exercises for you to complete
1. Demonstrate you successfully followed the steps in this lab by
preparing screen captures of you
running the lab as specified in the Instructions above.
2. Change the C code to sum 10 integers as opposed to 5? (Hint: Please
don’t use arrays or Loops
for this. We will be using those features in another week.) Support your
experimentation with a
screen capture of executing the new code 3. Using the code you create in
step 1, modify the code to print an additional statement if the sum
of the value is negative (Hint: Consider modifying the existing selection
statement) Support your
experimentation with a screen capture of executing the new code. 4.
Prepare a new test table with at least 3 distinct test cases listing input
and expected output for
the code you created after step 2.
5. Create your own C code implementation of one of the following
mathematical formulas:
a. y = mx + b; (slope of a line) Assume the user will be prompted to
input m, x and b and
the program will calculate y. If the value of y is greater than 10, inform
the user the
19. value is greater than 10.
b. a = PI * r*r; (area of circle). Assume the user will be prompted to
input the radius r. You
can define PI as 3.1416. . If the value of a is greater than 10, inform the
user the value is
greater than 10.
c. v = 4/3 PI r*r*r; (volume of sphere) Assume the user will be
prompted to input the
radius r. You can define PI at 3.1416. If the value of v is greater than 10,
inform the user
the value is greater than 10.
Be sure you provide not only the C code but a test table with at least 3
distinct test cases listing
input and expected output your mathematical formula. Submission
Submit a neatly organized word (or PDF) document that demonstrates
you successfully executed this lab
on your machine using an online compiler. You should provide a screen
capture of the resulting output.
Submit all C code you created in files.
Also, provide the answers and any associated screen captures of your
successful completion of exercises
1, 2, 3 and 4.
Submit your document no later than the due date listed in the syllabus or
calendar.
20. 5 Grading guidelines
Submission
Demonstrates the successful execution of this Lab within an
online compiler. Provides supporting screen captures.
Modifies the C code to sum 10 integers as opposed to 5.
Supports your experimentation with screen captures of
executing the code.
Using the code created in step 1, modifies the code to print
an additional statement if the sum of the value is negative
Supports your experimentation with a screen capture of
executing the new code.
Provides a new test table with at least 3 distinct test cases
listing input and expected output for the code you created
after step 2.
Creates your own unique C code implementation of one of
the provided mathematical formulas. Provides a new test
table with at least 3 distinct test cases listing input and
expected output your mathematical formula. Supports your
experimentation with a screen capture of executing the new
code.
Document is well-organized, and contains minimal spelling
21. and grammatical errors.
Total Points
2
2 2 1 2 1
10 6
**********************************************************
CMIS 102 Week 5 Hands-On Lab
For more classes visit
www.snaptutorial.com
CMIS 102 Week 5 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 (using pseudocode), and implementation with
22. C code. The example provided uses sequential, selection and repetition
statements.
Program Description
This program will calculate the average of 10 positive integers. The
program will ask the user to 10 integers. If any of the values entered is
negative, a message will be displayed asking the user to enter a value
greater than 0. The program will use a loop to input the data.
Analysis
I will use sequential, selection and repetition programming statements. I
will define two integer numbers: count, value and sum. count will store
how many times values are entered. value will store the input. Sum will
store the sum of all 10 integers. I will define one double number: avg.
avg will store the average of the ten positive integers input.
The sum will be calculated by this formula:
Learning Exercises for you to complete
1. Change the code to average 20 integers as opposed to 10. Support
your experimentation with screen captures of executing the new code.
2. 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.
3. What happens if you entered a value other than an integer? (For
example a float or even a string). Support your experimentation with
screen captures of executing the code.
4. Modify the code to allow the user to enter an unspecified number of
positive integers and calculate the average. In other words, the user
could enter number of positive integers. (Hint: You can prompt the user
for how many they want to enter. Or; you could use a sentinel value to
23. trigger when the user has completed entering values). You may need to
conduct some research on your own to solve this problem. Prepare a new
test table with at least 3 distinct test cases listing input and expected
output for the code you created. Support your experimentation with
screen captures of executing the new code
**********************************************************
CMIS 102 Week 6 Hands-On Lab
For more classes visit
www.snaptutorial.com
CMIS 102 Week 6 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 statements and nested repetition
statements.
Program Description
24. This program will calculate the average of 3 exams for 5 students. The
program will ask the user to enter 5 student names. For each of the
students, the program will ask for 3 exam scores. The average exam
score for each student will be calculated and printed.
Analysis
I will use sequential and repetition programming statements.
I will define one String to store the student name: StudentName.
I will define three Float numbers: Examvalue, Sum, Avg to store exam
values the sum of the exams and the average of the exams.
The sum will be calculated by this formula:
Sum = Sum + Examvalue
For example, if the first value entered was 80.0 and second was 90.0 and
the third exam was 100.0: sum = sum + Examvalue = 0.0 + 80.0
sum = 80.0 + 90.0 = 170.0
sum = 170.0 + 100.0 = 270.0
Avg is then calculated as:
Avg = sum/3.0
For example 270.0/3.0 = 90.0
A nested repetition loop can be used to loop through each of the 5
students and each of the 3 exams:
For (students=0; students <5; students++) For
(exams=0;exams<3;exams++) End For End For Sum values will need to
be reset for each student to ensure only one student data is used for
calculations each time.Test Plan
25. To verify this program is working properly the input values could be
used for testing:
Learning Exercises for you to complete
1. Modify the code to be able to input an undetermined number of
students. You will still only have 3 exams for each student. Support your
experimentation with screen captures of executing the new code.
2. 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.
3. What is the line of code doing?
charStudentName[100];
(Hint: We haven’t covered arrays, but a String can be thought of as an
array of characters) ?
4. What would happen if you moved the Set Sum = 0.0 from inside the
for loop to right after the declaration. For example:
// Declare variables
Declare StudentName as String Declare ExamValue, Sum, Avg as Float
// Initialize Sum Set Sum = 0.0;
Support your experimentation with screen captures of executing the new
code.
**********************************************************
CMIS 102 Week 7 Hands-On Lab
26. For more classes visit
www.snaptutorial.com
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
27. 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:
Learning Exercises for you to complete
1. 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
28. probably be a double type.) Support your experimentation with screen
captures of executing the new code.
2. 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.
3. 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.
4. 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.
**********************************************************
CMIS 102 Week 8 Hands-On Lab
For more classes visit
www.snaptutorial.com
CMIS 102 Week 8 Hands-On Lab
29. Overview:
This hands-on lab allows you to follow and experiment with the critical
steps of developing a program including the program description,
Analysis, Design(program design, pseudocode), Test Plan, and
implementation with C code. The example provided uses sequential,
repetition, selection statements, functions, strings, and arrays.
Program Description:
This program will input and store meteorological data into an array. The
program will prompt the user to enter the average monthly rainfall for a
specific region and then use a loop to cycle through the array and print
out each value. The program should store up 5 years of meteorological
data.
Analysis:
I will use sequential, selection, and repetition programming statements
and an array to store data.
I will define a 2-D array of Float number: Raindata[][] to store the Float
values input by the user. To store up to 5 years of monthly data, the
array size should be at least 5*12 = 60 elements.
A float number (rain) will also be needed to input the individual rain
data.
An integer variable (Count) is needed to keep count of how many rain
data elements were entered. This will keep track to make sure we don’t
go over 60 and we print only valid rain elements. In a 2D array this will
be RainData[5][12]. We can use #defines to set the number of years and
months to eliminate hard coding values.
30. A float number (rain) will also be needed to input the individual rain
data. A nested for loop can be used to iterate through the array to enter
Raindata. A nested for loop can also be used to print the data in the
array. A array of strings can be used to store year and month names.
This will allow a tabular display with labels for the printout. Functions
will be used to separate functionality into smaller work units. Functions
for displaying the data and inputting the data will be used.
A selection statement will be used to determine if data should be
entered.
Learning Exercises for you to try:
1. Modify the program to add a function to sum the rainfall for each year
(Hint: you need to sum for each year. You can do this using a looping
structure) Support your experimentation with screen captures of
executing the new code
2. Enhance the program to allow the user to enter another meteorological
element such as windspeed (e.g. 2.4 mph). Note, the user should be able
to enter both rainfall and windspeed in your new implementation.
Support your experimentation with screen captures of executing the new
code.
3. Prepare a new test table with at least 2 distinct test cases listing input
and expected output for the code you created after step 2
4. What happens if you change the NUMMONTHS and NUMYEARS
de finitions to other values? Be sure to useboth lower and higher values.
Describe and implement fixes for any issues if errors results. Support
your experimentation with screen captures of executing the new code.