0% found this document useful (0 votes)
37 views4 pages

Laboratory 5 (Partial Submission)

This document contains pseudocode and Python code for a payroll program. The pseudocode outlines getting the hourly pay rate and hours worked from the user with input validation. It then defines a function to calculate gross pay by multiplying the hourly pay rate by hours worked. The Python code implements these steps by defining functions to get the input, validate it, and calculate gross pay. It also adds a decorator to print welcome and thank you messages. The code calls the functions to run the payroll calculation.

Uploaded by

jamesdedase07
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)
37 views4 pages

Laboratory 5 (Partial Submission)

This document contains pseudocode and Python code for a payroll program. The pseudocode outlines getting the hourly pay rate and hours worked from the user with input validation. It then defines a function to calculate gross pay by multiplying the hourly pay rate by hours worked. The Python code implements these steps by defining functions to get the input, validate it, and calculate gross pay. It also adds a decorator to print welcome and thank you messages. The code calls the functions to run the payroll calculation.

Uploaded by

jamesdedase07
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/ 4

NAME: James Fritz M.

Dedase SR-CODE: 22-06913

SECTION: CpE-2105. DATE: November 14,,2023

A. PSEUDOCODE

Display "=== Welcome to the Payroll Program! ==="


Call func()
Display "=== Thank you for using the Payroll Program! ==="
Repeat:
Display "Enter hourly pay rate (Php 40.00 - Php 250.00):"
Try:
Read hourly_pay_rate as float
If 40.00 <= hourly_pay_rate <= 250.00:
Return hourly_pay_rate
Else:
Display "Invalid input. Pay rate must be in the range of Php 40.00 through Php
250.00."
Except ValueError:
Display "Invalid input. Please enter a valid number."

Repeat:
Display "Enter hours worked (0 - 48):"
Try:
Read hours_worked as float
If 0 <= hours_worked <= 48:
Return hours_worked
Else:
Display "Invalid input. Hours worked must be in the range of 0 through 48."
Except ValueError:
Display "Invalid input. Please enter a valid number."

Function compute_gross_pay():
hourly_pay_rate = Call get_hourly_pay_rate()
hours_worked = Call get_hours_worked()
gross_pay = hourly_pay_rate * hours_worked
Display "Employee's Gross Pay: Php " + Format(gross_pay, '.2f')

Call compute_gross_pay()
B. FLOWCHART
C. PROGRAM

def welcome_decorator(func):
def wrapper():
print("=== Welcome to the Payroll Program! ===")
func()
print("=== Thank you for using the Payroll Program! ===")
return wrapper

def get_hourly_pay_rate():
while True:
try:
hourly_pay_rate = float(input("Enter hourly pay rate (Php 40.00 - Php 250.00): "))
if 40.00 <= hourly_pay_rate <= 250.00:
return hourly_pay_rate
else:
print("Invalid input. Pay rate must be in the range of Php 40.00 through Php
250.00.")
except ValueError:
print("Invalid input. Please enter a valid number.")

def get_hours_worked():
while True:
try:
hours_worked = float(input("Enter hours worked (0 - 48): "))
if 0 <= hours_worked <= 48:
return hours_worked
else:
print("Invalid input. Hours worked must be in the range of 0 through 48.")
except ValueError:
print("Invalid input. Please enter a valid number.")

def compute_gross_pay():
hourly_pay_rate = get_hourly_pay_rate()
hours_worked = get_hours_worked()
gross_pay = hourly_pay_rate * hours_worked
print(f"\nEmployee's Gross Pay: Php {gross_pay:.2f}")

compute_gross_pay()

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy