将一个字符串转换x的数学函数:F(X)? [英] Convert a string into mathematical function of x :f(x)?

查看:197
本文介绍了将一个字符串转换x的数学函数:F(X)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,我是在Android的编程初学者。
我工作的一个图形计算器,但我仍然具有的功能转化为数学问题

Hello I'm a beginner in Android programming. I'm working on a graphic calculator but i still have the problem of converting the function to math

例如:

y=cos(x^2)-ln(x)

应该像

y=Math.cos(x*x) - Math.log(x)

和比我们绘制它。

感谢您

推荐答案

我假设你想要一个字符串转换为float或double?

I assume you want to convert a String to a float or double?

String input = "3.14";
float x = Float.parseFloat(input);

这code字符串3.14转换为浮动。你可以使用这个漂浮在你的问题中描述的功能。

This code converts the String "3.14" into a float. You can use this float in the function you described in the question.

编辑:
如果你想的全功能字符串转换成Java code转换,您应该限制输入按钮。例如,添加一个名为的Cos按钮,在$ C $记住c中的用户想要使用的Cos函数。然后用户输入的值,和presses输入。在code知道它应该使用余弦函数,x是一个EditText输入的值。这值应使用Float.parseFloat()被解析。

If you want to convert the full function String into Java code, you should limit the input to buttons. For example, add a button named "Cos", and remember in the code the user wants to use the Cosinus function. Then the user enters a value, and presses "Enter". The code knows it should use the cosinus function, and x is the value entered in an EditText. That value should be parsed using Float.parseFloat().

这篇关于将一个字符串转换x的数学函数:F(X)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆