Uploaded by Adebole Oreoluwa

CIT203 ASSIGNMENT 2

advertisement
ADEBOLE OREOLUWA OMOTOLA
BU19CIT1002
200LEVEL CIT
1) Write
algorithm for a program to compute
and print the area and perimeter of a
rectangle with length L and breadth B:
a.) Get the values of L, B,
b.) Calculate the Area of the rectangle using
the formula = L * B,
c.) Calculate the Sum using the formula = L +
B,
d.) Calculate the Perimeter of the rectangle
using the formula = 2 * Sum,
e.) Output the values for Area and
Perimeter,
f.) STOP.
2)
Question Two:
a.) Write algorithm for a program to compute
the roots of a quadratic equation • ax2 + bx +
c = 0 given by
Provided b2 – 4ac ≥ 0 :
𝑥=
−𝑏±√𝑏 2 −4𝑎𝑐
2𝑎
ADEBOLE OREOLUWA OMOTOLA
BU19CIT1002
200LEVEL CIT
START
INPUT a, b, c
discrim =√(( b2 )– 4*a*c)
Y
discrim ≥ 0
X1 = (- b + discrim) / 2 *a
X2 = (- b - discrim) / 2 *a
X = X1 & X2
OUTPUT X, X1, X2, discrim
N
STOP
ADEBOLE OREOLUWA OMOTOLA
BU19CIT1002
200LEVEL CIT
b.) A program is to input salary and gender of an employee
and output the tax payable. A male employee pays 10%
of his salary as tax while a female counterpart pays 5%
of her salary as tax. Design the algorithm for the
program:
 Input NAME
 Input SALARY
 Input GENDER
 IF GENDER = Male then

TAX = (SALARY * 10 )/100
 ELSE

TAX = (SALARY* 5)/100
 ENDIF
 Output NAME, SALARY, GENDER, TAX.
 Stop.
3) I.)
o Set Kounter = 0
o Do while (Kounter < 10)
 Input names, cit201score, cit203score and
cit205score
 Calculate totalscore = cit201score + cit203score +
cit205score
 Compute averagescore = totalscore / 3
 If averagescore > 50 then

Remark = ”Pass”
ADEBOLE OREOLUWA OMOTOLA
BU19CIT1002
200LEVEL CIT
 Else

Remark = “Fail”
 Endif
 Output names, cit201score, cit203score,
cit205score, averagescore, Remark
 Kounter = Kounter + 1
o Enddo
o Stop
II.)
o Input N
o Set Kounter = 0
o Do while (Kounter < N)
 Input names, cit201score, cit203score and
cit205score
 Calculate totalscore = cit201score + cit203score +
cit205score
 Compute averagescore = totalscore / 3
 If averagescore > 50 then

Remark = ”Pass”
 Else

Remark = “Fail”
 Endif
 Output names, cit201score, cit203score,
cit205score, averagescore, Remark
ADEBOLE OREOLUWA OMOTOLA
BU19CIT1002
 Kounter = Kounter + 1
o Enddo
o Stop
200LEVEL CIT
Download