0% found this document useful (0 votes)
4 views18 pages

Pseudocode

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views18 pages

Pseudocode

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 18

21

Pseudocode
Variables Used:

Start

number_1

number_2

larger_number

smaller_number

Display “ Enter the First Number”

Accept number_1

Display “Enter the Second Number”

Accept_number_2

If number_1 > number_2

Then number_1 = larger_number

number_2 = smaller_number

Else if number_1 < number_2

Then number_2 = larger_number

number_1 = smaller_number

Display larger_number “is greater than” smaller_number


End

Flowchart

22
Pseudocode
Start

Variables Used:
pincode = 340023

Display “input pin”

input_pin
Accept input_pin

If input_pin != pincode

Display “Sorry you have entered the wrong pincode!”

Else if input_pin = pincode

Display CONGRATULATIONS! You entered the correct pincode!”

End

Flowchart

23
Pseudocode
Start

Variables Used:

number
positive_number

negative_number

Display “Enter an integer number:”


Accept number

If number >= 1

Then number = positive_number

Display positive_number “is a positive number”

Else if number <= -1

Then number = netagive_number

Display negative_number “is a negative number”

End

Flowchart
24
Pseudocode
Start

Variables Used:

number

input number

Display “Enter a number from 0 – 10”

switch number

Case 0:
Display “Zero”

Case 1:

Display “One”

Case 2:

Display “Two”

Case 3:

Display “Three”

Case 4:

Display “Four”

Case 5:

Display “Five”

Case 6:

Display “Six”

Case 7:

Display “Seven”
Case 8:

Display “Eight”

Case 9:

Display “Nine”

Case 10:

Display “Ten”

Default

Display “Wrong Number”

End switch

End

Flowchart
25
Pseudocode
Start

Variables Used:

num_hours

wage

gross_pay

Display “ ==============================”

Display “ ABC COMPANY PAYROLL”

Display “ ==============================”

Display “ Enter number of hours worked: “

Display “ Enter your hourly rate:”

Display “ ==============================”

Input num_hours

Input wage

gross_pay = ( 40 * wage) + (1.5 * wage * ( num_hours – 40)

Display “Gross pay is:” gross_pay

End

Flowchart
26
Pseudocode
Start

Variables Used:
Color
Mode

Red

Blue

Steady

Flashy

Display “Enter a Color, Red or Blue”

Accept Color

Display “Enter a Mode, Steady or Flashing”


Accept “Mode”
If Color = Blue
If Mode = Steady

Then

Display “ Color of the light [Blue/red]” Color

Display “ Mode [S or F]” Mode

Display “The Weather Today is CLEAR VIEW”

Else if Mode = Flashing

Then

Display “ Color of the light [Blue/red]” Color

Display “ Mode [S or F]” Mode

Display “The Weather Today is Clouds Due”

Else if Color = Red

If Mode = Steady

Then

Display “ Color of the light [Blue/red]” Color

Display “ Mode [S or F]” Mode

Display “The Weather Today is Rain Ahead”

Else if Mode = Flashing

Then

Display “ Color of the light [Blue/red]” Color

Display “ Mode [S or F]” Mode

Display “The Weather Today is Snowing Instead”

End

Flowchart
27
Pseudocode
Start

Variables Used:

Equipment

Day_Type

Half_Day

Full_Day

Deposit = 300

Total
Rug_Cleaner, Lawn_Mower, Paint_Sprayer

Display “ Price of Equipment | Half-day | Full-Day|”

Display “ Rug Cleaner |160 |240 |”

Display “ Lawn Mower |120 |180 |”

Display “ Paint Sprayer |200 |300 |”

Display “Input Equipment”


Display “Input Day Type”

Input Equipment

Input Day_Type

H_Rug = 160

F_Rug = 240

If Equipment = Rug Cleaner

Input Day_Type

If Day_Type = H_Rug

Then Display Rug_Cleaner “php” 160 “(Half Day Rental)”

Display “Deposit php:” Deposit

H_Rug + Deposit = Total

Display “php:”Total

Else If Day_Type = F_Rug

Then Display Rug_Cleaner “php” 240 “(Full Day Rental)”

Display “Deposit php:” Deposit

F_Rug + Deposit = Total

Display: “php:”Total
H_Lawn = 120
F_Lawn = 180

If Equipment = Lawn_Mower

If Day_Type = H_Lawn

Then Display Lawn Mower “php” 120 “(Half Day Rental)”

Display “Deposit php:” Deposit

H_Lawn + Deposit = Total

Display “php:”Total

Else If Day_Type = F_Rug

Then Display Rug_Cleaner “php” 240 “(Full Day Rental)”

Display “Deposit php:” Deposit

F_Lawn + Deposit = Total

Display: “php:”Total

H_Paint = 200
F_ Paint = 300

If Equipment = Paint_Sprayer

If Day_Type = H_ Paint

Then Display Paint_Sprayer “php” 120 “(Half Day Rental)”

Display “Deposit php:” Deposit

H_ Paint + Deposit = Total

Display “php:”Total

Else If Day_Type = F_ Paint

Then Display Paint_Sprayer “php” 240 “(Full Day Rental)”

Display “Deposit php:” Deposit

F_ Paint + Deposit = Total


Display: “php:”Total

End

Flowchart

28
Pseudocode
Start

Variables used: weight, height, bmi, customerName, thin, healthy, overweight, obese, bmiValue

Display “IDEAL WEIGHT BASED UPON BMI”

Display “customerName”

Accept customerName

Display “Enter your weight in pounds:”


Accept weight

Display “Enter your height in inches:”

Accept height

Bmi = (703 * weight) / (height * height)

If bmiValue <= 18.5

Then bmiValue = thin

Else if bmiValue = 18. < x < 24.9

Then bmiValue = healthy

Else if bmiValue = 25 < x < 29.9

Then bmiValue = overweight

Else if bmiValue => 30

Then bmiValue = obese

Display “BMI is” bmiValue“You are” meaning

End

PROBLEM 29: SEVEN PROVERBS

PROBLEM 30: NUMBER OF DAYS IN A MONTH

Flowchart

29
Start

Variables
Proverb

correct_answers

Proverb = ["The squeaky wheel gets the grease.", "Cry and you cry alone.", "Opposites attract.",
"Spare the rod and spoil the child.", "Actions speak louder than words.",

"Familiarity breeds contempt.", "Marry in haste, repent at leisure."]

truth_values = [True, True, False, False, True, False, True]

correct_answers = 0

proverb_value

for each proverb, truth_value in zip(proverbs, truth_values):

Display proverb

Accept truth_values

truth_values = proverb

if proverb_value is equal to truth_value:

increment correct_answers

Display = "Continue"

if correct_answers is equal to 7:

Display = "Perfect"

else if correct_answers is greater than or equal to 5:

Display = "Excellent"

display "You got {correct_answers} out of 7 correct. Result: {result}"

End

30
Start

Variables Used:
year

month

days

Display “Input a Year”

Input Year

If (year % 4 == 0 AND year % 100 != 0) OR (year % 400 == 0):

Then = True

Else:

Then = False

Display if true “It is a Leap Year”

Else “It is not a Leap Year”

Input month, year

If month = [1, 3, 5 ,7 ,8, 10, 12]:

Then return = 31

Else IF month = [4, 6, 9, 11]:

Then return = 30

Else IF month == 2:

If is_leap_year(year):

Then Return = 29

Else

Then Return = 2

Display “Enter the month (1-12):”

Input month

If 1 <= month <= 12:


If month == 2:

Display “Enter the year:”

Input year

days = (month, year)

Else

Days = month, 0

If days != -1:

Display “ The number of days in month” month “ is:” days

Else

Display “Invalid month input”

End

You might also like