def calculate(num1, operator, num2):
    if operator == "+":
        return num1 + num2
    elif operator == "-":
        return num1 - num2
    elif operator == "*":
        return num1 * num2
    elif operator == "/":
        if num2 != 0:
            return num1 / num2
        else:
            return "Error: Division by zero"
    else:
        return "Error: Invalid operator"

def main():
    keep_running = True
    while keep_running:
        num1 = float(input("Enter the first number: "))
        operator = input("Enter the operator (+, -, *, /): ")
        num2 = float(input("Enter the second number: "))

        result = calculate(num1, operator, num2)
        print("Result:", result)

        choice = input("Do you want to perform another calculation? (y/n): ")
        if choice.lower() != "y":
            keep_running = False

    print("Calculator program has ended.")

if __name__ == "__main__":
    main()