Two Laptop Bag*
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
Author

problem with writing calculator application

lida abdi
Greenhorn

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
Marshal

Joined: Mar 22, 2005
Posts: 41096
    
  44
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
Bartender

Joined: Oct 02, 2003
Posts: 11153
    
  16

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
Marshal

Joined: Mar 22, 2005
Posts: 41096
    
  44
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: http://aspose.com/file-tools
 
subject: problem with writing calculator application
 
Similar Threads
Read files and replace Strings
hello
A simple calculator help!
Help with Layout
Comparing 2 Strings with 1?