Programming Challenges... Again

Want to just shoot the breeze? Forum 42 is the place!

Moderator: Moderators

Post Reply
joevennix
Portablizer
Posts: 999
Joined: Sat Jan 14, 2006 9:34 am
Location: On permanent vacation from reality.

Programming Challenges... Again

Post by joevennix »

Alright, so I slacked off last time. Summer always seems to make me lazier than ever, and I guess I just stopped adding new ones. Well now I'm back and better than ever, coming at you with Programming Challenge 2.0.

Can be written in any language, I will only judge Java, C, and C++. Here goes:

Code: Select all

Programming Challenge 4 / July 27, 2007
(remember today is the 84th anniversary of James Coney Island, so go down there and get as many 84 cent hot dogs as you can). Back on topic:

You've been commissioned by TI to write a working command-line version of their low-end calculator model. It will need to be able to take in a string (or char[]) of up to 88 characters, establish order of operations, and output the answer. No parentheses will be used, and there will be no spaces in the input. Output will be a simple double.

Sample input:
C:/> ti-calc 8+9+33*3*7*1+0-0-33/2/1

Sample output (Crap this took a long time to figure out) :
694.5

Rounding would be nice, but is not necessary. If implemented, round to the nearest thousandth's (or 3rd decimal place).
This is kind of a tough one in C++, Strings are a lot easier to work with in Java, but I'm sure it can be done. May need a few helper methods.

PM your source to me and I'll post it when next Friday. Let me know what you think of the new challenge. Good luck.
Image
Skyone
Moderator
Posts: 6390
Joined: Tue Nov 29, 2005 8:35 pm
Location: it is a mystery
Contact:

Post by Skyone »

Oh pfft - should be easy! :P I'll get to work.
Post Reply