So I have been programming a scientific calculator using Java for a school project, and I have become stuck on two things here.
Adding functions such as ReactDOM.render(
<Router history={browserHistory}>
<Route path="/" component={App}>
<IndexRoute component={Directory} />
<Route path="feed" component={Feed} />
<Route path="page">
<Route path="about" component={About}/>
</Route>
<Route path="*" component={Four04Page}/>
</Route>
</Router>,
document.getElementById('app')
);
, sin
, cos
, tan
etc. With this, I am stuck on a way to separate arguments. For example, root(base,n)
. I can figure out how to read the equation on my own, I am using the Shunting Yard algorithm to convert the equation to RPN. I have been following this pseudo-code algorithm to implement it. I just cant figure out how to allow the user to add both arguments using only the onscreen GUI.
Implementing an advanced display. So by this I mean a display that doesn't just have one line of text, but multiple lines such as root(base,n)
, the previous equation and answer, and the current equation/answer. If my explanation is bad, this might help illustrate my point:
Currently my display uses a simple JTextField, and I am aware of its limitations for what I want to do, and that I will definitely need to change it. The JTextField was kind of a temporary way to display the output until I got to making the display properly.
My calculator GUI currently looks like this:
It basically has two strings, one is the one to be evaluated, and the other is what is displayed on the screen, with unicodes etc that can't be evaluated in an equation (hence the power two symbol and the x instead of asterisk)
For the first issue, I think the left arrow and right arrows should move between arg1, arg2 etc. But I don't know how I would achieve this.
Any help with either of these issues would be greatly appreciated. I have been trying to solve this for a few hours now...
Thanks.
答案 0 :(得分:1)
Given that root(base, n) = base ^ (1 / n), the input logic could be similar. I would suggest that when the user clicks on the n-root button, a left bracket opens and the display (or status bar) indicates they must enter the base. When they close with a right bracket, they then enter n.
For the advanced display I'm not so sure, maybe a JFormattedTextField?