Question
#7 List 4 main data types we used in this course and describe the data that is stored in each one. List examples of variable
#7 List 4 main data types we used in this course and describe the data that is stored in each one. List examples of variable names that make sense for each data type.
(10 points)
#8 Debug this input validation function and fix it. There is a lot wrong with it!
Function Integer getNumberGreaterThanX(msg, x)
myInteger = getInteger(msg)
While myInteger < x
Display "The number must be < , myInteger , . Try again."
Input x
End While
End Function
Write the corrected function below:
(10 points)
#9 Write a validation function based on the provided variables and call statement below. The validation function should return an Integer value greater than zero or print an error message until an acceptable value is entered.
Declare Integer positiveValue = 0
Declare String message = "Enter the year you were born (no negative numbers!)"
positiveValue = getNumberGreaterThanZero(message)
Write the function definition below:
(10 points)
#10 Write the pseudocode statements that will take the given array, multiply each value by 2, and save the results into a new array. Then, display every value in the new array using a loop.
Constant Integer SIZE = 5
Declare Real myRealArray [SIZE] = 12.5, 13, 13.5, 14, 14.5
Write the pseudocode below:
(2 points each; 20 total)
#11 Do these statements evaluate to be true or false?
NOT true evaluates to:
true AND true evaluates to:
false OR NOT false evaluates to:
true OR false evaluates to:
false AND false evaluates to:
false OR true evaluates to:
NOT false AND true evaluates to:
(NOT (true OR false)) AND true evaluates to:
(NOT true) OR (NOT false) evaluates to:
NOT (false OR (NOT true)) evaluates to:
(NOT ((false AND false) AND (true OR false)) OR (true OR NOT false)) evaluates to:
(2 points)
#12a - Define what source code refers to:
What is the file extension used for Python source code?
(2 points)
#12b - Define what executable code refers to:
What is a file extension used for executable code?
(4 points)
#12c -Fill in the definitions below and provide examples for each:
Logic error:
An example of a pseudocode logic error would be (explain why):
Syntax error:
An example of a pseudocode syntax error would be (explain why):
(2 points)
#13a In OOP, explain what encapsulation means:
(2 points)
#13b In OOP, explain what a constructor is and what its purpose is:
(2 points)
#13c Complete this common phrase used in OOP:
Private ______________; Public _________________
(2 bonus points)
What is the meaning of the above phrase? Give an example.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started