Thread: Desperate to get help w/ program

  1. #1
    Unregistered
    Guest

    Angry Desperate to get help w/ program

    I'm not asking anyone to do my homework but I am desperate to get help. I need a huge boost in the right direction. My program is to calculate the value of an expression involving arithmetic operators. The expression should be evaluated based on operator precedence. The program should prompt the user to input the expression and should indicate the end of the expression by inputting a character E. The expression should have only numeric values and operators to add, subtract, multiply, and divide.

    -The program should prompt the user to input only integer values
    -the program should be written for integer values in the expression
    -Arrays should be used to store the input values of the user
    -Output of the program should be an integer value
    -Functions can be used if necessary
    here is an example that a user might enter
    "34*2-8+6/3E"
    the program should display the correct answer and the numbers stored as integers and the operators stored as char. Please someone help me out anyway you can. Thank you.

  2. #2
    Registered User
    Join Date
    Sep 2001
    Posts
    412
    Are parentheses allowed? Like:

    (1+2)/3E

    ?

    Is whitespace valid? So, would:
    Code:
    1        + 4/    2        E
    be valid?

    Also, are there limits to the maximum number of numbers/operators?

    How much have you learned? These problems can be solved with a stack, but I don't know if you've learned about that. You can also use recursion to solve this.
    Last edited by The V.; 10-13-2001 at 01:21 PM.

  3. #3
    Unregistered
    Guest
    no recursion is NOT allowed, yes white spaces can be used and the maximum will be around 500 integers or so, depending on what i want it to be. and no pointers allowed either.

  4. #4
    Unregistered
    Guest
    Is the use of parenthesis allowed? Without recursion, this is much more difficult. Parenthesis processing is way easier with recursion. You can of course, fake recursion, using a loop. This isn't nearly as clean to read, but it can be done.

    Quzah.

  5. #5
    Unregistered
    Guest
    we can also right the program so it goes like this:
    34
    *
    2
    +
    5
    E
    and then it produces the answer
    is that easier than the way i said before?
    Thank you.

  6. #6
    Unregistered
    Guest
    the way i just said, the:
    34
    *
    2
    etc......
    i mean by that the user types in a number, hits return, enters an operation, then another number and so on.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Using variables in system()
    By Afro in forum C Programming
    Replies: 8
    Last Post: 07-03-2007, 12:27 PM
  2. BOOKKEEPING PROGRAM, need help!
    By yabud in forum C Programming
    Replies: 3
    Last Post: 11-16-2006, 11:17 PM
  3. Can someome help me with a program please?
    By WinterInChicago in forum C++ Programming
    Replies: 3
    Last Post: 09-21-2006, 10:58 PM
  4. My program, anyhelp
    By @licomb in forum C Programming
    Replies: 14
    Last Post: 08-14-2001, 10:04 PM