如何在Java中编写金融方程?

huangapple 未分类评论48阅读模式
英文:

How to write an Financial equation in Java?

问题

我目前正在一个项目中工作,该项目涉及创建一个类似金融计算器的程序。然而,我目前遇到了一些问题,希望能从社区的人那里获得一些意见或获取一些知识。目前我正在使用Java Gradle和应用程序窗口,并且正在实际编写我的代码。然而,我在如何编写方程式方面遇到了问题,不确定是否应该在if循环中循环方程式,还是创建不同的类,以便一个类文件中不会有太多循环。在这一点上,我还想指出,我也在项目中使用Eclipse应用程序。

我目前正在编写的方程式是一个单一现金流,即FV = PV(1+i)^n,我不知道是否应该这样编写,或者我是否只是在过度思考方程式,实际方程式可能与所示方程式完全不同。如果是这样的话,我们是否需要对n开方?如果是的话,如何进行呢?

我感觉我可能过度思考了我的项目,无法看到眼前的问题。因此,请传授你的智慧给我。另外,有没有金融应用程序可以通过GitHub导入或安装,而不是使用npm?如果有任何链接,你们认为会有帮助的,请在下面友好地提供链接。因为我已经多次重新编写了我的代码,感觉一无所获。谢谢。

以下是不在Gradle应用程序窗口中的代码部分。

package Finance.Calculator.Project;

import static java.lang.Math.*;
import java.text.*;
import java.io.*;

public class SimpleFinanceCalc {
    public double FutureValue;
    public double PresentValue;
    public double NumYears;
    public double NumComYear;
    public double Interest;
    public double Growth;
    public double CashFlow;
    public String Operator;

    public SimpleFinanceCalc(double FutureValue, double PresentValue, double NumYears, double NumComYear, double Interest, double Growth, double CashFlow, String Operator) {
        this.FutureValue = FutureValue;
        this.PresentValue = PresentValue;
        this.NumYears = NumYears;
        this.NumComYear = NumComYear;
        this.Interest = Interest;
        this.Growth = Growth;
        this.CashFlow = CashFlow;
    }

    public Double Calculate() {
        if (this.Operator.equals("Single Cash Flow")) {
            return PresentValue * (1 + Interest) * Math.sqrt(NumYears);
        }
    }
}
英文:

I am currently working on a project which includes creating a program that runs similar to a financial calculator. However I am currently in a fix and would like to get some opinion or gain some knowledge form people within this community. Currently I am using Java gradle and application window and is in the process of actually writing my code. However I am in a fix on how to write the equations and if I should loop the equations in if loops or create different classes so there is not so many loops in one class file. On that note I would also like to note that I an using the Eclipse application for the project too.

The equation I am writing currently is a single cash flow which is FV = PV(1+i)^n and I don't know if I should or am able to write it like this or if I am just over thinking on equation and its totally different from the equation shown. If it is would we need to root the n and if so, how?

I feel like I am over thinking my project and can't see pass what is in front of me. So please past me your wisdom. On another note. Is there a financial application we can or would be able to import or install using github that is not a npm? Also if there is any links that you guy think would help please so kindly link it down below please. For I have restarted my code several times already and feel like I am not getting anywhere. Thank you.

Here is a portion of my code that is not within the gradle application window.

package Finance.Calculator.Project;


import static java.lang.Math.*;
import java.text.*;
import java.io.*;



public class SimpleFinanceCalc {
	public double FutureValue;
	public double PresentValue;
	public double NumYears;
	public double NumComYear;
	public double Interest;
	public double Growth;
	public double CashFlow;
	public String Operator;
	
	
	public SimpleFinanceCalc (double FutureValue, double PresentValue, double NumYears, double NumComYear, double Interest, double Growth, double CashFlow, String Operator){
		this.FutureValue = FutureValue;
		this.PresentValue = PresentValue;
		this.NumYears = NumYears;
		this.NumComYear = NumComYear;
		this.Interest = Interest;
		this.Growth = Growth;
		this.CashFlow = CashFlow;
		
	}		
	
	public Double Calculate() {
		if(this.Operator.equals("Single Cash Flow")) {
			return PresentValue * (1 + Interest) Math.sqrt(NumYears)
		}
		
	
	}


	
	
	
}

huangapple
  • 本文由 发表于 2020年4月7日 10:15:45
  • 转载请务必保留本文链接:https://java.coder-hub.com/61071781.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定