• 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
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

Need Help building Calculator

 
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,
I am building a 4 functions calculator program, it is accepting a number then at next line an Arithmetic Operator then at another line another number then show calculation on only single operator.
i need help to modify it to accept data like this
12 + 12 - 2 * 2 = 20 as wel or
100 / 2 + 200 = 250 i mean it have to perform calculation from all four operators on single line or two or three

here is a program which is getting input like this
12
+
12
24
that i don't want.


i shall wait for you answers !
if you have an example code for this pupose send me i will study from that.

regards,
Muzafar
 
Ranch Hand
Posts: 159
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sorry but we are NotACodeMill. If you really did that code, you could easily do what you want just by looking at Scanner and String documentations.
 
Muzafar Ali
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Eduardo Bueno wrote:Sorry but we are NotACodeMill. If you really did that code, you could easily do what you want just by looking at Scanner and String documentations.


I know sir you are not a code mil,
i don't say that correct it as i say, i say that provide me sample which could work like that i shall study on that and after that i shall use that code in my program, you say that use Scanner and String documentation i will follow that now i shall study on those .

Thanks,
Muzafar
 
Marshal
Posts: 80230
424
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you are planning to use precedences, you need to look at a tutorial about parsing, convert the infix expression to postfix, and calculate in postfix.
 
Ranch Hand
Posts: 61
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You could implement a stack data structure to your program for the operands and the operators including the "(" ")" parenthesis. It would be simpler to evaluate a postfix expression than to an infix expression.
 
30 seconds to difuse a loaf of bread ... here, use this tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic