Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

problem with writing calculator application

 
lida abdi
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Rancher
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Bartender
Posts: 12123
30
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Ulf Dittmer
Rancher
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm just noticing that the "i" loop starts at 0 - that will cause "str.substring(0, i-1)" to throw an exception.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic