Untitled

mail@pastecode.io avatar
unknown
plain_text
7 months ago
1.4 kB
1
Indexable
Never
# User Input
number_of_trips = int(input("Number of Trips: "))

for trip in range(number_of_trips):
    # Input for day type, boarding time and total distance
    day_type = int(input("Day Type (1 = Weekdays, 2 = Weekends/PH): ")) # surcharge
    boarding_time = int(input("Boarding time in 24-hour and minute: ").replace(" ", "")) # surcharge
    total_distance = int(input("Distance travelled: "))

    # Define constants for day type
    weekdays = 1
    weekends_PH = 2

    # Determine constants for time range
    midnight = range(0, 600)
    morning_peak_hour = range(600, 930)
    evening_peak_hour = range(1800, 2360)

    # Determine basic condition
    basic_distance = 1000
    flag_down = 3.90

    # Calculate additional distance charge
    if total_distance <= basic_distance:
        basic_fare = 3.90
    else:
        additional_distance = total_distance - basic_distance
        distance_charge = (additional_distance / 400) * 0.22
        basic_fare = flag_down + distance_charge

    # Calculate surcharge based on boarding time and day type
    surcharge = 0
    if boarding_time in midnight:
        surcharge = basic_fare * 0.5
    elif boarding_time in morning_peak_hour and day_type == 1 or boarding_time in evening_peak_hour:
        surcharge = basic_fare * 0.25

    # Calculate total fare
    total_fare = basic_fare + surcharge

    # Print the result
    print("Total fare: ${dollars}".format(dollars = total_fare))