You are on page 1of 3

Portfolio - Programme 3.

Iteration Programming Exercise (Weighting 15%) MARKS 15

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.

Open the data file. (Name, rate of pay, hours worked).


Print report title and column headings
For each employee:
read the employees data record
calculate net, gross and pay deductions (see programme 1)
print the employee pay and deduction details
Print end of Report line

Marks awarded for Programme (maximum 10 marks)

Item Mark awarded


Indentation & sensible variable names 2
Comment header giving students name etc 1
Program 5
Screen shot of output – showing program runs & produces results 2
Marks deducted for help given 0

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

Ian O’Neill (40071909)

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

Portfolio - Programme 2. Selection Programming Exercise


*/
#include <iostream>
#include <string>
using namespace std;

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;

if (bmi >= 0 && bmi <= 15)


{
cout << "Seriously underweight." << endl;
}
else if (bmi >= 16 && bmi <= 17)
{
cout << "Underweight." << endl;
}
else if (bmi >= 18 && bmi <= 23)
{
cout << "Normal weight." << endl;
}
else if (bmi >= 24 && bmi <= 28)
{
cout << "Overweight." << endl;
}
else if (bmi >= 29 && bmi <= 34)
{
cout << "Seriously overweight." << endl;
}
else
{
cout << "Gravely overweight." << endl;
}

cout << "\n";

You might also like