Sunteți pe pagina 1din 10

DESIGN AND ANALYSIS OF

ALGORITHM
Assignment #01

Muhammad Asif Qayyum


FA17-BCS-125
Mam Muniba Firdous
23-09-2019
1.Determine whether the given number is even or odd.
Algorithm:
1. Start.
2. [Take input from user] Read: Number
3. Check if modulus of Number with 2 equals to 0.
4. If answer is 0 - Number is Even.
5. Else Number is Odd
6. Finish

Pseudo Code:
READ Number
Reminder=Number%2
IF Reminder==0
PRINT “Number is Even”
ElSE
PRINT “Number is Odd”

2.Determine Whether the input temperature is below freezing point


or above.
Algorithm:
1. Start.
2. [Take input from user] Read: Area
3. Read: Temperature
4. Check if Temperature is less than 32℉
5. If True, display -Below freezing point
6. Else display Above freezing point
7. Finish

Pseudo Code:
READ Area
READ Temperature
IF (Temperature < 32F)
SHOW “Below Freezing point”
ELSE
SHOW “Above Freezing point”

3.Should I do my Assignment.
Algorithm:

1. Start
2. [Check Assignment on Portal] Read: Assignment status
3. If Assignment not available
4. Don’t do it.
5. Else, If Assignment is Available,
6. Check Due date
7. If Due date Available
8. Download Assignment and Complete Assignment
9. Else Do not do Assignment
10. Step 4: Finish

Pseudo Code:
READ Assignment
IF(Assignment == Available)
IF(AssignmentDueDate ==Available)
Download Assignment
Complete Assignment
Submit
ELSE
Skip Assignment
ELSE:
Assignment is not uploaded yet.

4.Find interest on tax


Algorithm:
1. Start
2. [Take input from user of amount time and current]
READ Principal Amount, Time Years, Rate Yearly
3. Principal Amount as PA,
Time Years as TY and
Rate Yearly as RY
4. Calculate Interest by formula ofInterest (PA*TY) *(RY/100)
5. OutputInterest
6. End

Pseudo Code:
READ PA, TY, RY
Interest =(PA*TY) *(RY/100)
Print: Interest

5.Find net-pay of employee and categorize employees on the basis of


grades.
Algorithm:
1. Start
2. [Input Basic salary from user] Read: BasicSalary
3. [Calculate Basic required parameters] Calculate DearnessAllowence,
HouseRentAllowence, GrossSalary, ProvidentFund and NetPay.
4. Calculate, DearnessAllowence=(0.25*BasicSalary)
5. Calculate,HouseRentAllowence=(0.15*BasicSalary)
6. Calculate,GrossSalary(BasicSalary
+DearnessAllowence+HouseRentAllowence)
7. Calculate,ProvidentFund=(GrossSalary*0.10)
8. Calculate,NetPay(GrossSalary-ProvidentFund)
9. Output Net-Pay
10. Now, If employees NetPayis greater than 80.0 the grade should be ‘A’
11. If employees NetPayis greater than or equal to 73 and less than 80 the
grade should be ‘B+’
12. If employees NetPayis greater than or equal to 66 and less than 70 the
grade should be ‘B’
13. If employees NetPay is less than 66 the grade should ‘C’
14. Finish

Pseudo Code:
FLOAT CalculateNetPay( BasicSalary, DearnessAllowence,
HouseRentAllowence, GrossSalary, ProvidentFund, NetPay)
START
Read BasicSalary
FLOAT DearnessAllowence=(0.25* BasicSalary)
FLOAT HouseRentAllowence =(0.15* BasicSalary)
FLOAT GrossSalary = BasicSalary + DearnessAllowence + HouseRentAllowence
FLOAT ProvidentFund =(GrossSalary *0.10)
FLOAT NetPay = GrossSalary – ProvidentFundDSIPLAY “Net Salary of
Employee is: NetPay”
IF (NetPay>=80.0)
SHOW “Grade A”
ELSE
IF (NetPay >=73.0&&NetPay <80)
SHOW“Grade B+”
ELSE
IF (NetPay >=66&&NetPay <70)
SHOW “Grade B”
ELSE
SHOW “C
Flow Chart 1: Start

Read Number

NUMBER%2= false
=0

true
Display Odd Number

Display Even Number

Finish
Flow Chart 2: Input Area Input Temperature

Start

TRUE Temperature<
Below Freezing Point
32

FALSE

Above Freezing Point

Finish

Flow Chart 3
Start

Check portal for


Assignment

Assignment == True
Available

False Due date

== Available

Do not do Assignment
False True

Do not Assignment Do Assignment

Finish
Flow Chart 4:

Start Input PA Input TY

Input RY

Interest =(PA*TY) *(RY/100)

Finish
Flow Chart 5:

Start DearnessAllowence =0.25* BasicSalary


Read BasicSalary

-s

GrossSalary = BasicSalary + DearnessAllowence + HouseRentAllowence =(0.15* BasicSalary)


HouseRentAllowence

-s
-s

ProvidentFund = (GrossSalary *0.10) NetPay = GrossSalary – ProvidentFund

-s

SHOW NetPay

NetPay>=73&
&NetPay <80 NetPay >=80

False
FALSE True
True
Output Grade A
FALSE output B+ Output A
Output Grade B+

NetPay >=66 True


and NetPay
Output Grade B
<70

False

OutputGrade C

Finish

S-ar putea să vă placă și