CSIS 434
HOMEWORK: UNDERSTANDING STRUCTURE, MAKING DECISIONS INSTRUCTIONS
OVERVIEW/INSTRUCTIONS
This assignment is worth up to 50 points. Each question is worth up to 10 points. Feedback will
be provided in this file via comments Point deductions will be available in the rubric for each
question. Additional points will be deducted if these instructions are not followed.
Treat each problem separately. Do not remove any formatting from this file or from the
pseudocode specifically. Keep all images and instructions in this file. Provide your answers in this
file. See below for more specific requirements for each type of problem (pseudocode, flowchart
or diagram, and essay).
Pseudocode is provided for several of the problems. Do NOT rewrite the entire pseudocode. You
will NOT receive any credit for complete rewrites. Instead, mark any additions to the
pseudocode by adding new lines in red font or showing changes to existing lines (where
changed only) in red font. Strikeout any deletions using the strikeout tool and show those in red
font. Do NOT change variable names or function names unless mismatches exist or non-
conformance is present. Do NOT rewrite the entire program because you have a better way. For
example, do not create new functions but instead add code to existing functions when possible.
All main programs should begin with start and end with stop and all functions should end with
return. All comments should begin with //. Adding more comments is not desired or expected.
Assignment operators such as not equal to can be in text format or can use != symbols. A while
loop starts with while and ends with endwhile. An if statement begins with if and can use else,
and ends with endif. Constants should be in all upper case to follow proper naming convention.
New or existing variables should follow camel case convention (see assignment resources in
Canvas for more information about camel case). Variables declared in the main (start/stop)
program area are considered global and do not have to be passed down to each function as this
is pseudocode. Inputs do not need to be validated (i.e., assume they meet data type standards,
etc.). An = (equal sign) is an assignment operator. It assigns a value to a variable, while the == is
a comparison operator. It compares the value of two variables. If they are equal then it returns
true, otherwise it returns false. NOTE: If a function has no changes to be made to it, then it will
be in blue font.
Any flowcharts or class diagrams provided are images. Describe the changes needed below the
flowchart or diagram in a bullet list using specifics from the flowchart or diagram to describe
what needs changed and where (i.e., reference functions by name, identify if in decision, input,
etc.). Do NOT redraw the entire flowchart or diagram. You will NOT receive any credit for
rewrites.
If an essay is required (i.e., #5), use full sentences and provide references in proper APA format
with at least one in-text reference used where applicable for full credit. At least one external
Page 1 of 10
CSIS 434
scholarly reference is required for the first concept and is highly recommended for the second
concept (in addition to your textbook).
1. // Modularize the flowchart below by describing any new function(s) that should be created
to
// reduce duplication of code and ease maintenance. Name the new function(s) and //
what each would contain and how this would make the current program more efficient
and // less to maintain. No pseudocode needs to be written for this problem. No changes
to logic // are needed.
To restructure the program into a modular format, we can develop distinct functions for
each logical segment of the code, thereby improving readability, reusability, and
maintainability.
Here’s an overview of the newly proposed functions and their respective roles:
•‘isQuestionMark(s)’ Funciton:
oDescription: This function assesses whether the provided string concludes
with a question mark.
oImplementation: It’s a straightforward function designed to verify the last
character of the given string.
•‘isYesNoQuestion(s)’ Function:
Page 2 of 10
CSIS 434
oDescription: This function evaluates if a string constitutes a yes/no question
by checking if it ends with a question mark and contains either “Yes” or “No”.
o Implementation: This involves merging the logic from the existing code
that examines the presence of a question mark and the inclusion of “Yes” or
“No”.
•‘processBlock(s)’ Function:
oDescription: It handles processing each code block to determine if it is a
yes/no question and outputs the result as required.
oImplementation: This function can leverage the ‘isYesNoQuestion’ function to
evaluate and display the pertinent message.
•‘main()’ Function:
oDescription: Acts as the central part of the program that manages its
workflow. It goes through each code block and invokes the ‘processBlock’
function.
oImplementation: It can house the existing code logic for iterating through
blocks and calling ‘processBlock’.
By organizing the program using these functions, the structure becomes clearer and more
intuitive. Each function assumes a specific task, enhancing the code’s maintainability. The
primary advantage is that any future modifications or enhancements can be performed within
individual functions without impacting the entire program’s structure.
2. Examine the pseudocode below, then find and correct all the bugs.
// This pseudocode is intended to determine whether students have passed //
or failed a course; a student needs to average 60 or more on two tests
// to pass. Don’t forget to use priming read prior to while loop. Find and
// fix all bugs.
start
// Declarations
num firstTest num
secondtest string
num average num
PASSING = 40 60
output "Enter first score or 0 to quit "
input firstTest
while firstTest not equal to 0 output
"Enter first score or 0 to quit "
input firstTest
output "Enter second score"
input secondtest
average = (firstTest + secondTest) / 2
ouput "Average is ", average if
Page 3 of 10
CSIS 434
average >= PASSING then output
"Pass"
else
output "Fail"
endif
endwhile stop
3. Examine the pseudocode below, then find and correct all the bugs.
// The pseudocode below should create a report that contains an apartment
// complex rental agent's commission. The program accepts the ID number
// first and quits when user enters number 9999. The program also gets
the // name of the agent who rented the apartment and the number of
bedrooms in
// the apartment. The commission is $100 for renting a three-bedroom
// apartment, $75 for renting a two-bedroom apartment, $55 for renting a
// one-bedroom apartment, and $30 for renting a studio (zero-bedroom)
// apartment. Output is the salesperson’s name and ID number and the //
commission earned on the rental. Find and fix all bugs.
start
Declarations num
salesPersonID string
salesPersonName num
numBedrooms num COMM_3 =
$100.00 num COMM_2 =
$75.00 num COMM_1 =
$55.00 num COMM_STUDIO =
$20.00 num QUIT = 9999
getReady()
while salesPersonID <> QUIT
detailLoop()
endwhile
finish() stop
getReady()
output "Enter salesperson ID or ", QUIT, " to quit "
output salespersonID
end return
detailLoop() output
"Enter name " input
salesPersonName
output "Enter number of bedrooms rented "
input numBedrooms if
numBedrooms = 3 then
commissionEarned = COMM_3
else
if numBedrooms = 2 then
commissionEarned = COMM_2
else
if numBedrooms = 1 then
commissionEarned = COMM1
else
commissionEarned = COMM_4 COMM_STUDIO
Page 4 of 10
CSIS 434
endif
endif
output salesPersonID, salesPersonName, commissionEarned
output "Enter salesperson ID or ", QUIT, " to quit "
input salesPersonID
return
finish() output "End of report"
return
4. Examine the flowchart image below and then document and correct all errors using a bullet
list. Do NOT redraw chart or write pseudocode. This is not pseudocode. It is a flowchart. At
least 4 items should be bullet listed.
See flowchart on next page …
Page 5 of 10
CSIS 434
•A ‘return’ needs to be added after the mpg is calculated to keep the loop going until
a ‘0’ is inputted to end the program
•‘num END_VAL’ needs to be set to zero as that is the number needed to quit the
program as stated
•‘input mile’ needs to be changed to ‘input miles’ as ‘num miles’ is what is declared
•‘Declarations’ needs to be changed to ‘// Declarations”
•Need to make sure ‘num gallons’ will handle values of 1 or more
5. This week, we have covered several key concepts from the assigned chapters in the
textbook.
For this assignment, please do the following:
1. First Concept:
oIdentify one concept from the assigned chapter(s) for this week. o Thoroughly
summarize the concept as it is explained in the textbook. Be sure to reference the
specific chapter name, section, and page number (if available). (Note: Do not copy
text verbatim from the textbook; doing so will result in point deductions.)
oFind and reference one additional external scholarly source that provides
further detail, a different perspective, or a practical application of this concept
with examples. o Discuss how this new information enhances your understanding.
Use thorough coded examples and provide complete explanation.
2. Second Concept:
oIdentify another concept from a different chapter than the one used above that
was assigned in the reading this week. o Thoroughly summarize this second concept
as it is explained in the textbook. Again, reference the specific chapter name,
section, and page number (if available). (Note: Do not copy text verbatim from the
textbook; doing so will result in point deductions.)
oProvide a unique, Python coded example in text format (in addition to
screenshots showing its execution) that illustrates this concept in action. This
example should not be found in the textbook and needs to execute successfully. o
Explain the code, its purpose, and how it helps to further understand the concept
(not in comments in program but in paragraph form clearly identified). Provide any
necessary references. o Ensure the code runs properly and includes sample inputs
and outputs.
Make sure to cite all sources in APA format. Your response should demonstrate a deep
understanding of the concepts and their applications.
First Concept: Understanding the three basic structures
In chapter 3 section 2 the book describes the three basic structures, sequence and
selection and loop, used for programming, or as the book talks about it the only structures
needed to solve any problem. The structures can theoretically be combined in any number of
Page 6 of 10
CSIS 434
ways by either stacking or nesting them. Each of the structure types only have a single entry and
exit point. Each structure can connect to another structure only at one of these points. Logical
steps can be rewritten to conform to any of the three structures to make sure it will remain
logical.
Sequential logic depends on a series of instructions given to the computer, unless a
change in instructions is given the program will continue to flow in an obvious sequence.
Sequential logic:
If (condition) then:
[Module A]
[End of if structure]
Selection logic on the other hand uses conditions or parameters that decide which module to
use, there are three different types of conditional structures. Single alternative structures are
simple if statements while double alternative structures are an if-else statement, the last is
called a multiple alternative which is and ‘if-else if’ statement.
Selection logic:
If (condition) then:
[module A] Else:
[module B]
[End of if structure]
The last is a loop structure which causes a statement to repeat until an exit clause happens
which causes the algorithm to end. The loop structure is used to keep collecting data from a
user until the user no longer needs to add information.
Multiple Alternative:
If (condition C) then:
[module C]
Else if (condition D) then:
[module D]
. . .
. . .
Page 7 of 10
CSIS 434
Else if (condition m) then:
[module m]
[End of if structure]
References:
Farrell, J. (2018). Programming Logic and Design: Introductory. Cengage Learning.
GeeksforGeeks. (2025, July 12). Control structures in programming languages. GeeksforGeeks.
https://www.geeksforgeeks.org/dsa/control-structures-in-programming-languages/
Second Concept: Understanding ‘AND’ Logic
In Chapter 4, Section 3 of the book, the concept of using 'AND' logic is explained in a
practical and straightforward way, focusing on its application in programming projects (Farrell,
2018). Basically, 'AND' logic allows us to evaluate multiple conditions before reaching a final
decision. This is most often seen in if-then or if-else statements, where decisions are based on
more than one criterion.
One of the critical parts of using 'AND' logic effectively is figuring out which condition to
evaluate first. While it might seem like it doesn't matter, if you have relevant information, you
can prioritize the most logical condition first. This smart ordering means the program might
reach the decision faster, minimizing the number of checks it has to perform. It saves both
memory and time, making the process more efficient. However, if you don’t have any extra
information, it’s usually better to start with the condition that’s less likely to be true, since this
might save some computing effort if it fails right away. Overall, understanding how to utilize
'AND' logic can significantly optimize decision-making in programs. def check_access(password,
is_authorized_user):
correct_password = "securePass7927"
Page 8 of 10
CSIS 434
if password == correct_password and is_authorized_user:
return "Access granted" else:
return "Access denied"
password_input = input("Please enter your password: ") is_authorized_user = True
access_result = check_access(password_input, is_authorized_user) print(access_result)
Page 9 of 10
CSIS 434
The code that I came up with is meant as a password checker to make sure the user is
authorized. The password is saved as a variable and then the user is asked to provide a
password to check against. If the password is correct then it shows that the user is authorized,
if the password is incorrect then is shows that the user is denied access. This program helps
further the concept in that it asks if the password is correct and if they are an authorized user,
it only shows the user has access if both conditions are true.
References:
Farrell, J. (2018). Programming Logic and Design: Introductory. Cengage Learning.
10 of 10