• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

problem with writing calculator application

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
lowercase baba
Posts: 13089
67
Chrome Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Brace yourself while corporate america tries to sell us its things. Some day they will chill and use tiny ads.
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic