我试图通过将变量tri2
包装在 中toDegree()
并将其设置为一个名为triDegree
. 但是当我转换变量并运行应用程序时,我在 logcat 中得到以下信息:http: //pastebin.com/HKDSAuQK
该应用程序运行良好并计算到我将其转换为度数的地步。谁能在这里看到我的实施有什么问题?
public void onClick(View v) {
// TODO Auto-generated method stub
try {
String getoffsetlength = data.offsetLength.getText().toString();
String getoffsetdepth = data.offsetDepth.getText().toString();
String getductdepth = data.ductDepth.getText().toString();
double tri1,tri2;
double marking1,marking2;
double triDegree;
double off1 = Double.parseDouble(getoffsetlength);//length
double off2 = Double.parseDouble(getoffsetdepth);//depth
double off3 = Double.parseDouble(getductdepth);//duct depth
marking1 = Math.sqrt(Math.pow(off1,2) + Math.pow(off2,2));
tri1 = Math.atan(off2 / off1);
tri2 = (180 - tri1) / 2;
triDegree = Math.toDegrees(tri2);
marking2 = off3 / Math.tan(triDegree);
Intent myIntent = new Intent(MainActivity.this, CalcResult.class);
myIntent.putExtra("number1", marking1);
myIntent.putExtra("number2", marking2);
startActivity(myIntent);
//make a toast
Toast.makeText( getBaseContext(), "Calculating!", Toast.LENGTH_SHORT
).show();
}
catch (NumberFormatException e) {
// TODO: handle exception
System.out.println("Must enter a numeric value!");
}
}