#!/usr/bin/env python

def parse_scientific(val):
    """
    Converts a string like '3,35*10^-5' into a valid float.
    Steps:
    1. Removes spaces.
    2. Replaces ',' with '.' (European to US decimal).
    3. Replaces '*10^' or '*10' with 'e' (Scientific notation).
    """
    # Clean up the input string
    val = val.strip().replace(" ", "")  # Remove spaces
    val = val.replace(",", ".")         # Change comma to dot
    val = val.replace("*10^", "e")      # Handle *10^ style
    val = val.replace("*10", "e")       # Handle *10 style (just in case)

    return float(val)

def calculate_buoyant_force():
    # Gravity constant
    g = 9.81

    print("--- Physics II Buoyancy Calculator ---")
    print("Format example: 3,35*10^-5 or 0,005\n")

    try:
        # Get raw input as text first
        raw_liquid = input("Enter Density (MEliquid) [kg/m^3]: ")
        me_liquid = parse_scientific(raw_liquid)

        raw_vol = input("Enter Volume (VolObject) [m^3]: ")
        vol_object = parse_scientific(raw_vol)

        # Calculate the 'push' (Buoyant Force)
        push_force = me_liquid * vol_object * g

        # Output results
        print(f"\nInputs recognized:")
        print(f"  Density: {me_liquid} kg/m^3")
        print(f"  Volume:  {vol_object} m^3")
        print(f"\nThe Buoyant Force (Push) is: {push_force:.4e} Newtons")

    except ValueError:
        print("\nError: Could not understand the number format.")

if __name__ == "__main__":
    calculate_buoyant_force()
