SIT105 Assignment 2

Verified

Added on  2019/10/31

|4
|541
|179
Homework Assignment
AI Summary
This assignment, SIT105 Assignment 2 from Trimester 2 2017, focuses on critical thinking and problem-solving skills within an IT context. The document presents several problems requiring the development of algorithms and flowcharts. The problems involve tasks such as calculating income tax based on annual salary, finding the average and count of specific numbers in an array, calculating the average of even numbers up to a given limit, and analyzing family sizes to determine the maximum number of children, the number of families with no children, and the number of families with more than four children. The solutions provided include defining diagrams, algorithms written in pseudocode, and hierarchy charts, demonstrating a structured approach to problem-solving and algorithm design.
Document Page
SIT105 Critical Thinking and Problem Solving for IT Assignment 2 Trimester 2 2017
Name:
ID:
tabler-icon-diamond-filled.svg

Paraphrase This Document

Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser
Document Page
1. Defining Diagram
Input Processing Output
annualSalary Input annualSalary annualSalary
If annualSalary <=0 then
Print error
Input annualSalary again
If annualSalary <= 18200 then
Tax = 0
If annualSalary <= 37000 then
Tax = (annualSalary – 18200) * 0.19
If annualSalary <= 80000 then
Tax = 3572 + (annualSalary – 37000)*0.325
tax
If annualSalary <= 180000 then
Tax = 17547 + (annualSalary – 80000)*0.37
If annualSalary >= 180001 then
Tax = 54547 + (annualSalary – 180000)*0.45
Print annualSalary and tax
2. Algorithm
Declare an array A with size 11 //array to store the 11 numbers
For i=0 to 11: //loop to input all no’s in array
Input A[i] //Input number
Declare avg = 0 //variable to store the average
Declare count = 0 //variable to store the count of 6
For i=0 to 11: //loop to check each number
avg = avg + A[i] //add each number to avg
IF A[i] = 6 then: //if number is 6
count = count + 1 //increment count
avg = avg/11 //avg is total divide by 11
PRINT avg and count //Print the values
3. Algorithm
DEFINE calculate(P): //function to calculate average
Declare total = 0 //variable for total of all even no.s
Declare count = 0 //variable for count of even nos
For i= 2 to P: //loop to check each even no
IF i%2 = 0 then: //if number is even
total = total + i //add number to total
count = count + 1 //increment count
Declare avg = total/count //avg is total divide by count
RETURN avg //return average to calling func
Document Page
END
MAIN function:
Input P //Input p
While P <=0: //loop for error if p is negative
Print error message
Input P
avg = CALL calculate(P) //Call calculate method for avg
Print avg //print avg on screen
4.
i. Algorithm
Main function:
Declare max = 0 //variable to store the max value
Declare noChildren = 0 //variable to store the no children count
Declare moreThan4 = 0 //variable to store the more than 4 count
Do: //loop to input no
Input n //Input no
IF n >=0 and n!=999 then: //if no is greater than 0 and not equal 999
IF n = 0 then: //if family has no children
noChildren++ //increment noChildren
IF n >4 then: //if family has more than 4 children
moreThan4++ //increment moreThan4
IF max<n then: //if max is less than n
Max = n //update max
While n!=999 //loop while user enters 999
Print noChildren, moreThan4 and max
ii. Hierarchy Chart
Document Page
iii. Defining Diagram
Input Processing Output
all numbers For all numbers: noChildren
If num = 0 then
noChildren++
If num > 4 then
moreThan4++
moreThan4
If max > num then
Max = num
Max
chevron_up_icon
1 out of 4
circle_padding
hide_on_mobile
zoom_out_icon
[object Object]