Ealing Group 13 - Assignment 1
Ealing Group 13 - Assignment 1
Introduction To
Programming
STU97458
Taiwo Akinmuyisitan
554
Task 1:
As part of our building task, first we must start by determining the combined
area of a single room. Using a Calculate Area code we can determine the area
of a single room by inputting the values provided to us (2m x 4m).
Then after determining the amount of Metes of Wood each room will require,
we must multiply the total area of a room by the amount of rooms in a single
house to find out the total amount of Wood needed for a single house. To do
this we can use a Multiplication Code that will give us the result after imputing
the values we have, which in this case is the number of rooms (3) and meters
per room (8). And since all rooms are identical, the result won’t be impacted.
Then, after establishing the total number of meters per house, we can then use
the same code to find out the amount of meters for all five houses.
And finally, after receiving the total amount of meters of every house we can
then use the same code one last time to determine the cost of completing this
project, which in this case will be the number of total meters times the price of
one meter of wood.
Pseudocodes:
A) BEGIN B) BEGIN
Input Length Input number 1 & 2
Input Width Multiply N. 1 by N. 2
Multiply Length by Width Output
Output END
END
Task 2:
In order to arrange the values provided in the required order, we must use a
Bubble Sort code, which is the simplest type of sorting algorithm. Using Bubble
Sort we can arrange a given array in ascending order and this is done by taking
each number from first to last and comparing them to the one next to them, if
a number is greater than the one next to it, it is then swapped with the smaller
number.
After the code goes through each number and switches them, the array will be
given in ascending order from the smallest number to the highest.
Pseudocode:
A) BEGIN
loop = list.count;
swapped = false
swap them
swapped = true
end if
end for
break
Task 3:
To separate each number into their respective categories, we must use an Odd
Even Separation code, which will take any given array of numbers and check
each if each individual number it can be divided by two. If a number can be
divided it is moved to the first area where all even numbers are, if it cannot be
divided by two than it is moved to the last area where all odd numbers are.
If we scramble around these numbers for example, the program will be able to
recognise which is odd and which is even and arrange them in their respective
columns.
Pseudocode:
A) BEGIN
Input Numbers
Output as ‘Even Numbers’ if;
Number MOD 2= 0
Output as ‘Odd Numbers’ if;
Number MOD 2 does not = 0
Output
END