Professional Documents
Culture Documents
You are required to write a simple Payroll data processing programme using the scenario detailed
below. The finished program takes input from a serial file and provides report-based output to the
monitor. You need to lay your code out in a proper fashion. Make sure to use indentation and
annotation. Make sure the report is well-laid out using report titles and column headings.
You should include your name and the assessment worksheet number in a comment at the top of
your program and you should hand in a copy of your program code and a screen shot of the output
produced by your program.
Scenario
Write a program to read data records from a serial file. The data is payroll data for employees. Each
record consists of an employees’ name, their rate of pay and their hours worked. It needs to perform
the following tasks. The tasks are given in sequence.
Questions (5 marks)
Answer the following questions briefly using the source code from your solution:
Q1: what is a break out condition used in loop statements and how have you used them?
Q2. what is a deterministic loop is and how have you used them?
Q3. what is a non-deterministic loop is and how have you used them?
Q4. what does the term iteration processing structure mean and how have you used them?
Q5. what are nested loops and how have you used them?
Programme 2. Selection Programming Exercise
Q1: what is a condition and how have you used them in conditional statements?
A condition is used to decide which block of code to execute, conditions such as if, else and else-if
are used as well as the switch statement. I first use a condition on line 46:
Q2. what is a boolean expression and how have you used them?
A Boolean expression is when you use a comparison operator to determine if the statement is true
or false. I again use a Boolean expression on line 46:
Q3. what is a boolean data type and how have you used them.
A Boolean data type stores either values; true or false (1 or 0) and is declared using the bool
keyword. I have not had to use a bool in my code.
Q4. what does selection processing mean and how you have used it?
Selection processing is the use of if, else-if, else statements as questions for code blocks to execute.
I have used selection processing to determine the output text of the program.
Q5. what are logical operators and how have you used them?
There are 3 logical operators, && (AND), || (OR) and ! (NOT), these can be used as part of selection
processing to create more elaborate algorithms. I have used the AND logical operator though out to
determine the output for the entered BMI of the user.
/**
@author Ian W. O'Neill
@since 23 September 2020
int main()
{
/**
1. We first need to ask for the users Weight in Kilograms,
and their Height in meters.
*/
float weight = 0.0;
float height = 0.0;
cout << "Please enter your current Weight (Kg): " << endl;
cin >> weight;
cout << "Please enter your current Height (m): " << endl;
cin >> height;
/**
2. We now need to calculate the users BMI with the
given information, we do this by Weight/(Height)2.
*/
int bmi = weight / (height * height);
/**
3. And finally we output the BMI and classification
to the user.
*/
cout << "Your current BMI is " << bmi << ", " << endl;