This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
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

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
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: 41167
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.

Ping & DNS - my free Android networking tools app
fred rosenberger
lowercase baba

Joined: Oct 02, 2003
Posts: 11170

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: 41167
I'm just noticing that the "i" loop starts at 0 - that will cause "str.substring(0, i-1)" to throw an exception.
Consider Paul's rocket mass heater.
subject: problem with writing calculator application
Similar Threads
Read files and replace Strings
A simple calculator help!
Help with Layout
Comparing 2 Strings with 1?