Home Help & Support Search Tips Options: Case:



   Need A Tutor?    |   Need Homework Help?                                                                             Help and Support     | Join or Cancel

Exam  1     2     3     4     5     6     7    8     9    10     Midterm   1    2     Final Exam  1   2
Graded Program Assignment   
1   2    3    4    5    6    7    8    9           Python Compiler

Computer Programming
Assignment 4
AREAS RECTANGLES


AREAS_RECTANGLES #1

# PROGRAMMER:      Website Owner
# PROGRAM NAME:   Assignment #04 Part 3
# DATE WRITTEN:   January 5, 2019
# PURPOSE: Calculating Areas and Rectangles with If Statements
#
# Declare / Initialize Variables
recLength1 = 0.0;
recWidth1 = 0.0;
recArea1 = 0.0;
recLength2 = 0.0;
recWidth2 = 0.0;
recArea2 = 0.0;
 
# INPUT STATEMENTS
recLength1 = float(input("What is the length of Rectangle " + "01? "));
recWidth1 = float(input("What is the width of Rectangle " + "01? "));
recLength2 = float(input("What is the length of Rectangle " + "02? "));
recWidth2 = float(input("What is the length of Rectangle " + "02? "));
 
# Assignment Statement establish and Calculate the areas of rectangles
print("=" * 70)
recArea1 = recLength1 * recWidth1;
recArea2 = recLength2 * recWidth2;
 
# OUTPUT STATEMENTS
print("=" * 70)
print("Length #01 = " + format(recLength1, "10,.2f"))
print("Width #01 = " + format(recWidth1, "10,.2f"))
print("Area of Rectangle #01 = " + format(recArea1, "10,.2f"))
print("=" * 70)
print("Length #02 = " + format(recLength2, "10,.2f"))
print("Width #02 = " + format(recWidth2, "10,.2f"))
print("Area of Rectangle #02 = " + format(recArea2, "10,.2f"))
print("=" * 70)
print("=" * 70)
 
# If statement - determine and highlight if rectangle areas are equal
if recArea1 == recArea2:
   
    # The areas of rectangle #01 and rectangle #02 are equal
    print("The area of Rectangle #01 is equal to the area of Rectangle #02 ")
    print("=" * 70)
else:
   
    # If statement - determine and highlight if the area of rectangle #01 is greater than rectangle #02
    if recArea1 < recArea2:
       
        # the area of rectangles #01 is not equal but is greater than rectangle #02
        print("The area of Rectangle #02 is larger than the area of Rectangle #01 ")
        print("=" * 70)
    else:
       
        # the area of rectangles #02 is not equal but is greater than rectangle #01
        print("The area of Rectangle #01 is larger than the area of Rectangle #02 ")
        print("=" * 70)
 
# END PROGRAM
 

AREAS_RECTANGLES #2

# PROGRAMMER:      Website Owner
# PROGRAM NAME:    Assignment #04 – IF STATEMENTS
# DATE WRITTEN:    June 5, 2019
# PURPOSE: Illustrate calculations / assignment
# statements to calculate Gross Pay of an Employee
#
# Declare / Initialize Variables
grossPay = 0.0;
overTimeHours = 0.0;
overTimePay = 0.0;
regularPay = 0.0;
 
# INPUT STATEMENTS
employeeName = input("Enter the employee's Full Name: ");
hoursWorked = float(input("How many hours did " + employeeName + " work? "));
payRate = float(input("What is the rate of pay for " + employeeName + "? "));
 
# Assignment Statement
# Calculate the gross pay
# OUTPUT STATEMENTS
print("=" * 65)
print("PAYROLL INFORMATION FOR: " + employeeName)
print("=" * 65)
print("Hours Worked = " + format(hoursWorked, "10,.2f"));
print("Rate of Pay = $ " + format(payRate, "10,.2f"))
if hoursWorked > 40:
   
    # hours worked greater than 40
    # calculate over time info
    overTimeHours = hoursWorked - 40;
    overTimePay = overTimeHours * (payRate * 1.5);
    regularPay = 40 * payRate;
    grossPay = regularPay + overTimePay;
    print("OVER TIME HOURS = " + format(overTimeHours, "10,.2f"));
    print("OVER TIME PAY = $ " + format(overTimePay, "10,.2f"));
    print("REGULAR PAY = $ " + format(regularPay, "10,.2f"));
    print("GROSS PAY = $ " + format(grossPay, "10,.2f"));
else:
   
    # hours worked is less than or equal to 40
    grossPay = hoursWorked * payRate;
    print("Gross Pay   = $ " + format(grossPay, "10,.2f"))
print("=" * 65)
 
# END PROGRAM



Exam  1     2     3     4     5     6     7    8     9    10     Midterm   1    2     Final Exam  1   2
Graded Program Assignment   
1   2    3    4    5    6    7    8    9           Python Compiler


Home
Accounting & Finance Business
Computer Science General Studies Math Sciences
Civics Exam
Everything Else
Help & Support
Join/Cancel
Contact Us
 Login / Log Out