Chapter 7 Exam Style questions
1. The component parts of any computer
system are:
» inputs – the data used by the system that needs to be entered while the
system is active
» processes – the tasks that need to be performed using the input data and any
other previously stored data
» outputs – information that needs to be displayed or printed for the users of
the system
» storage – data that needs to be stored in files on an appropriate medium for
use in the future.
2. __________________________
|Calculate Check digit |
| | |
___________ ____________ __________
| Enter Num| |Perform check
| | digit calculation|
3.a For the number of diners, you could validate that it is an integer between 1
and 12. For the size of the bill, you could validate that it is a number between 10
and 500.
b. Here are two sets of normal data and their expected results:
Number of diners: 4 Bill size: $50 Expected result: $12.50 per person
Number of diners: 8 Bill size: $200 Expected result: $25 per person
c. Here are some examples of abnormal/erroneous data:
Number of diners: -1 Bill size: $50 Expected result: Invalid input
Number of diners: 13 Bill size: $200 Expected result: Invalid input
Number of diners: 4 Bill size: $0 Expected result: Invalid input
d. Number of diners: 1 Bill size: $10 Expected result: $10 per person
Number of diners: 12 Bill size: $500 Expected result: $41.67 per person
4. Validation and verification are two important concepts in software engineering.
Validation is the process of ensuring that a product, service, or system meets the
needs of its users and other stakeholders. It involves checking that the product or
system meets its requirements and specifications, and that it performs as expected.
Verification is the process of checking that a product, service, or system meets
its design specifications and requirements. It involves testing the product or
system to ensure that it works as intended and that it meets all of its design
goals.
In general, validation is concerned with ensuring that a product or system is
useful and usable, while verification is concerned with ensuring that it is correct
and reliable.
5. Here are some validation and verification checks that could be used for each
item:
Name Validation: Ensure that the name field is not empty and that it contains only
letters and spaces. Verification: Check that the name field contains a reasonable
number of characters (e.g., between 2 and 50 characters).
Date of birth Validation: Ensure that the date of birth field is not empty and that
it contains a valid date in the correct format (e.g., DD/MM/YYYY). Verification:
Check that the date of birth field contains a date that is within a reasonable
range (e.g., between 1900 and the current year).
Password Validation: Ensure that the password field is not empty and that it meets
certain complexity requirements (e.g., contains at least one uppercase letter, one
lowercase letter, one number, and one special character). Verification: Check that
the password field contains a reasonable number of characters (e.g., between 8 and
20 characters).
Phone number Validation: Ensure that the phone number field is not empty and that
it contains a valid phone number in the correct format (e.g., +1-555-555-5555).
Verification: Check that the phone number field contains a reasonable number of
digits (e.g., between 10 and 15 digits).
6.
7a. Here are the errors I found in the algorithm:
1. The variable Total is not initialized before it is used.
2. The FOR loop should not have a REPEAT-UNTIL loop inside it.
3. The condition in the FOR loop should be Counter <= 10 instead of Counter < 10.
4. The variable Total should be updated with Number instead of Counter.
5. The OUTPUT statement should be outside of the FOR loop.
b. Here's how the corrected algorithm would look like:
Total ← 0
FOR Counter ← 1 TO 10
OUTPUT "Enter a positive whole number "
INPUT Number
WHILE Number < 0
OUTPUT "Invalid input! Enter a positive whole number "
INPUT Number
END WHILE
Total ← Total + Number
END FOR
OUTPUT Total
c. Here's a trace table for the algorithm:
| Counter | Number | Total |
|---------|--------|-------|
| | | 0 |
| 1 | 15 | 15 |
| 2 | 10 | 25 |
| 3 | 20 | 45 |
| 4 | -5 | 45 |
| 5 | 30 | 75 |
| 6 | -10 | 75 |
| 7 | 25 | 100 |
| 8 | -5 | 100 |
| 9 | -10 | 100 |
| 10 | -20 | 100 |
Here's some test data you can use to dry run the algorithm:
15, 10, 20, -5, 30, -10, 25, -5, -10, -20
I hope that helps! Let me know if you have any other questions.
Here’s some test data you can use to dry run the algorithm:
15, 10, 20, -5, 30, -10, 25, -5, -10, -20
d. Here’s how you can classify each item of your test data:
Normal: 15, 10, 20, 30, 25
Erroneous: -5, -10
Extreme: -20
8a. Here's the trace table for the input data:
| Number1 | Number2 | Sign | Answer |
|---------|---------|------|--------|
| 5 | 7 | + | 12 |
| 6 | 2 | - | 4 |
| 4 | 3 | * | 12 |
| 7 | 8 | ? | 0 |
| 0 | 0 | / | |
8b. Here's an alternative type of conditional statement that you could use to
improve the algorithm:
```
IF Sign = '+'
THEN Answer ← Number1 + Number2
ELSEIF Sign = '-'
THEN Answer ← Number1 - Number2
ELSEIF Sign = '*'
THEN Answer ← Number1 * Number2
ELSEIF Sign = '/'
THEN Answer ← Number1 / Number2
ELSE
Answer ← 0
ENDIF
```
This alternative uses the ELSEIF statement to check for multiple conditions instead
of using multiple IF statements. This can make the code more concise and easier to
read.
9a. Verification is chosen to ensure that the data entered by the contributor is
accurate and valid. Verifying the name, email address, and password can help
prevent errors and fraud, as well as ensure that the contributor is authorized to
access the discussion group.
To verify this data, the programmer would typically use a combination of methods
such as email confirmation, password strength checks, and CAPTCHA tests. Email
confirmation can help verify that the email address entered by the contributor is
valid and that they have access to it. Password strength checks can help ensure
that the password is strong enough to prevent unauthorized access. CAPTCHA tests
can help prevent automated bots from creating fake accounts.
9b. To validate an email address, the programmer could use a combination of methods
such as manual email validation, password recovery tools, user validation, auto-
complete and syntax checker, and third-party validation tools. For example, manual
email validation involves looking at the address syntax, performing an IP address
lookup, and checking the DNS records. Password recovery tools can help verify that
the email address entered by the contributor is valid and that they have access to
it. User validation can help ensure that the contributor is authorized to access
the discussion group. Auto-complete and syntax checker can help prevent errors in
email addresses. Third-party validation tools can help validate email addresses in
real-time.
To validate a password, the programmer could use a combination of methods such as
password strength checks, password recovery tools, and password validation forms.
For example, password strength checks can help ensure that the password is strong
enough to prevent unauthorized access. Password recovery tools can help
contributors recover lost passwords. Password validation forms can help ensure that
passwords meet certain criteria such as length and complexity.