• 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

Need an idea for this program....!!!

 
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello ranchers...

I dont have much idea how to solve this problem.

Problem.
--------
Write a program or method, in which user will enter a mathematical expression as command line arguments. Program should print the answer...

Contraints.....
----------
[1]. Only three types of operation ca be done [sum, substarction and muliplication].
[2]. All the opertion must be there atleast once.
e.g. : 12 - 11 * 3 + 56 = Answer...
[3]. All te operands must be integer...
e.g. : a - 11 * b + 56 wont be accepted.....it should give an error message..


Urgent feedback is required.....for this problem..
Awaiting for the solution...
 
Ranch Hand
Posts: 1252
Spring Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Vishal K Patel:
Hello ranchers...

I dont have much idea how to solve this problem.

Problem.
--------
Write a program or method, in which user will enter a mathematical expression as command line arguments. Program should print the answer...

Contraints.....
----------
[1]. Only three types of operation ca be done [sum, substarction and muliplication].
[2]. All the opertion must be there atleast once.
e.g. : 12 - 11 * 3 + 56 = Answer...
[3]. All te operands must be integer...
e.g. : a - 11 * b + 56 wont be accepted.....it should give an error message..


Urgent feedback is required.....for this problem..
Awaiting for the solution...



First of all and very important is this relates to SCJP.....

Answer: Absolutely Not

Second, are you asking about the solution then you may use patterns and then try to get your own pattern.

And if you are asking about the code excatly then show your code and then let us do our work .
 
author
Posts: 23951
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


First of all and very important is this relates to SCJP.....

Answer: Absolutely Not



Agreed... this is more of a general question than SCJP question. Moving to Java in General, Intermediate.

Henry
 
Rancher
Posts: 3742
16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Vishal K Patel:
Awaiting for the solution...



Then you may have a very long wait. People don't just give solutions here.

Why don't you start with something simple. Read the command line arguments and validate them.
The command line arguments are in the String array passed to the main method of your class. You will need to check that the strings "*", "+" and "-" are found at least once each in the array. Any array element not containing one of those strings must contain a string representation of an integer.
Have a go at that. If you have any problems come back and post your code and details of what the problem is e.g. compilation error messages, runtime exceptions. Use code tags to post your code - it makes it easier to read.
 
reply
    Bookmark Topic Watch Topic
  • New Topic