File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes problem with writing calculator application Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "problem with writing calculator application" Watch "problem with writing calculator application" New topic

problem with writing calculator application

lida abdi

Joined: Aug 07, 2009
Posts: 2
please help me with that problem.I write aprogram of simple calculator but it dosen't work properly.I don't know where I had mistakes.
Ulf Dittmer

Joined: Mar 22, 2005
Posts: 42965
Welcome to JavaRanch.

There may be more problems, but for starters, note that string comparisons are done using the "equals" method in Java, not using the "==" operator. So wherever you have something like "if (src=="Clear")" you need to replace that with "if (src.equals("Clear")".

On an unrelated note, please go through this page to help you get the most out of the JavaRanch Saloon, in particular CarefullyChooseOneForum, UseAMeaningfulSubjectLine and UseCodeTags.
fred rosenberger
lowercase baba

Joined: Oct 02, 2003
Posts: 11955

I'd also suggest you ask more focused questions. Most people who see "this doesn't work" and then 150+ lines of code are going to simply move on.

tell us SPECIFICALLY what doesn't work. Only post the relevant code.

Also, I hope you didn't write all this code in one go, and now this is the first time you've run it. the best way to write code is to write tiny little chunks, maybe as little as one line, and then compile/run/test it until you're SURE it works. only THEN should you do any more.

There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
Ulf Dittmer

Joined: Mar 22, 2005
Posts: 42965
I'm just noticing that the "i" loop starts at 0 - that will cause "str.substring(0, i-1)" to throw an exception.
I agree. Here's the link:
subject: problem with writing calculator application
It's not a secret anymore!