/**
 * Computes the value of a foreign exchange forward contract.
 */
public class ForexFwd
{
    private double S;
    private double K;
    private double n;
    private double r;
    private double rf;
    private double t;
    
    public ForexFwd( double spot_exchange_rate,
                     double contracted_forward_exchange_rate,
                     double domestic_currency_to_exchange,
                     double domestic_interest_rate_for_maturity,
                     double foreign_interest_rate_for_maturity,
                     double years_to_forward_maturity )
    {
        S = spot_exchange_rate;
        K = contracted_forward_exchange_rate;
        n = domestic_currency_to_exchange;
        r = domestic_interest_rate_for_maturity;
        rf = foreign_interest_rate_for_maturity;
        t = years_to_forward_maturity;
    }
    
    public double value() {
        return n*(Math.exp(-rf*t)*K/S - Math.exp(-r*t));
        
    }
}
