Board index » delphi » help help help me!!!!

help help help me!!!!

is anybody know how to program this

"Pocket Calculator" Programming Exercise
Purpose: To introduce you to C (or refresh your memory, as the case may be)
by writing a small and self-contained program that does not need to make
any use of data structures or advanced language features.
Problem: Write a function EVAL that takes a character string and returns a
real (you may define EVAL to take additional arguments if you wish). If
EVAL is given a string s that is a legal arithmetic expression over
0,1,2,3,4,5,6,7,8,9,.,+,-,*,/,(, and ), then it should set s to be the
empty string and return the value of the expression. EVAL should supply a *
if an operator is missing (e.g. (1+2)3=9 or 1.6.5=.8); an empty input
string or an empty expression such as () is legal, but a missing argument
such as (1+) is illegal. Expressions should be evaluated from left to right
with no precedence given to operators (e.g. 1+2*3=9). If an illegal string
s is given to EVAL, then s can be assigned any non-empty string to signal
that an error was detected and an arbitrary value may be returned (or, if
you want to make your program a bit more "friendly", return error messages
through other arguments to EVAL or by setting s to an appropriate error
message). EVAL should be written in standard C where you write the code to
convert a string to a real number yourself and you make no use of any extra
built-in functions provided by the particular compiler that your are using.
What to do: After your program is working, make a listing that includes the
EVAL function itself (with a large header comment that describes how it
works), any utility routines that are used, and code that repeatedly asks
the user to enter an expression (or q to quit) and computes the value of
the expression. Along with this listing, include sample output that
provides evidence that your program works; in particular, include the legal
expressions
0, (((0))), 1+2*3, 1+(2*3), (1)(2+3), 1.6.5, -0, --1, 2+--2
and the illegal expressions: 1/0, 1++2, a, ..2, 1+2)
A slightly easier problem (75% credit): Allow only expressions that do not
contain any parentheses.
A slightly harder problem (extra credit): Give * and / higher precedence
than + and - (e.g. 1+2*3=7).

 

Re:help help help me!!!!


Sure you post your homework assignment without even attempting to do it
yourself.  And to top it all off you post in a Pascal group and program to
do in C.

--
Patti Handwerk
Patti...@prodigy.net

Quote
Wei Qi Luo wrote in message <01bde671$c3ac8c00$be024081@ppp>...
>is anybody know how to program this

>"Pocket Calculator" Programming Exercise

>  Lot's snipped.

>A slightly easier problem (75% credit): Allow only expressions that do not
>contain any parentheses.
>A slightly harder problem (extra credit): Give * and / higher precedence
>than + and - (e.g. 1+2*3=7).

Re:help help help me!!!!


We don't do any homeworks for you !!!
We just help you if you have specific problem

Michael

Wei Qi Luo schrieb:

Quote

> is anybody know how to program this

> "Pocket Calculator" Programming Exercise
> Purpose: To introduce you to C (or refresh your memory, as the case may be)
> by writing a small and self-contained program that does not need to make
> any use of data structures or advanced language features.
> Problem: Write a function EVAL that takes a character string and returns a
> real (you may define EVAL to take additional arguments if you wish). If
> EVAL is given a string s that is a legal arithmetic expression over
> 0,1,2,3,4,5,6,7,8,9,.,+,-,*,/,(, and ), then it should set s to be the
> empty string and return the value of the expression. EVAL should supply a *
> if an operator is missing (e.g. (1+2)3=9 or 1.6.5=.8); an empty input
> string or an empty expression such as () is legal, but a missing argument
> such as (1+) is illegal. Expressions should be evaluated from left to right
> with no precedence given to operators (e.g. 1+2*3=9). If an illegal string
> s is given to EVAL, then s can be assigned any non-empty string to signal
> that an error was detected and an arbitrary value may be returned (or, if
> you want to make your program a bit more "friendly", return error messages
> through other arguments to EVAL or by setting s to an appropriate error
> message). EVAL should be written in standard C where you write the code to
> convert a string to a real number yourself and you make no use of any extra
> built-in functions provided by the particular compiler that your are using.
> What to do: After your program is working, make a listing that includes the
> EVAL function itself (with a large header comment that describes how it
> works), any utility routines that are used, and code that repeatedly asks
> the user to enter an expression (or q to quit) and computes the value of
> the expression. Along with this listing, include sample output that
> provides evidence that your program works; in particular, include the legal
> expressions
> 0, (((0))), 1+2*3, 1+(2*3), (1)(2+3), 1.6.5, -0, --1, 2+--2
> and the illegal expressions: 1/0, 1++2, a, ..2, 1+2)
> A slightly easier problem (75% credit): Allow only expressions that do not
> contain any parentheses.
> A slightly harder problem (extra credit): Give * and / higher precedence
> than + and - (e.g. 1+2*3=7).

Re:help help help me!!!!


We don't do any homework for you !!!
We just help you if you have specific problems

Michael

Wei Qi Luo schrieb:

Quote

> is anybody know how to program this

> "Pocket Calculator" Programming Exercise
> Purpose: To introduce you to C (or refresh your memory, as the case may be)
> by writing a small and self-contained program that does not need to make
> any use of data structures or advanced language features.
> Problem: Write a function EVAL that takes a character string and returns a
> real (you may define EVAL to take additional arguments if you wish). If
> EVAL is given a string s that is a legal arithmetic expression over
> 0,1,2,3,4,5,6,7,8,9,.,+,-,*,/,(, and ), then it should set s to be the
> empty string and return the value of the expression. EVAL should supply a *
> if an operator is missing (e.g. (1+2)3=9 or 1.6.5=.8); an empty input
> string or an empty expression such as () is legal, but a missing argument
> such as (1+) is illegal. Expressions should be evaluated from left to right
> with no precedence given to operators (e.g. 1+2*3=9). If an illegal string
> s is given to EVAL, then s can be assigned any non-empty string to signal
> that an error was detected and an arbitrary value may be returned (or, if
> you want to make your program a bit more "friendly", return error messages
> through other arguments to EVAL or by setting s to an appropriate error
> message). EVAL should be written in standard C where you write the code to
> convert a string to a real number yourself and you make no use of any extra
> built-in functions provided by the particular compiler that your are using.
> What to do: After your program is working, make a listing that includes the
> EVAL function itself (with a large header comment that describes how it
> works), any utility routines that are used, and code that repeatedly asks
> the user to enter an expression (or q to quit) and computes the value of
> the expression. Along with this listing, include sample output that
> provides evidence that your program works; in particular, include the legal
> expressions
> 0, (((0))), 1+2*3, 1+(2*3), (1)(2+3), 1.6.5, -0, --1, 2+--2
> and the illegal expressions: 1/0, 1++2, a, ..2, 1+2)
> A slightly easier problem (75% credit): Allow only expressions that do not
> contain any parentheses.
> A slightly harder problem (extra credit): Give * and / higher precedence
> than + and - (e.g. 1+2*3=7).

Re:help help help me!!!!


Patricia Handwerk schrieb:

Quote

> Sure you post your homework assignment without even attempting to do
> it yourself.  And to top it all off you post in a Pascal group and > program to do in C.

The whole question does not seem meaningful. What he is searching
for, is a fully fledged string parser - not a typical homework
assignment for beginners. Regardless of the language C or Pascal.

Some 20 or more years ago I was searching for things like this and
tried to re-envent the wheel as usual these times. Now it is easy,
there are lots of parsers on the net, eg. in the numerics chapter
of the TP-links site.

Franz Glaser

Re:help help help me!!!!


In article <01bde671$c3ac8c00$be024081@ppp>, wei...@cs.brandeis.edu
says...
Quote
> is anybody know how to program this

> "Pocket Calculator" Programming Exercise
> Purpose: To introduce you to C (or refresh your memory, as the case may be)
> by writing a small and self-contained program that does not need to make
> any use of data structures or advanced language features.
> Problem: Write a function EVAL that takes a character string and returns a
> real (you may define EVAL to take additional arguments if you wish). If

snipped .....

Firstly, correct me if I am wrong but I think this is a pascal newsgroup
and not a C newsgroup.

Secondly, It is not very nice to ask other people to do your homework.

Re:help help help me!!!!


In article <36082CDE.71F3B...@eunet.at>, Ing. Franz Glaser <meg-
gla...@eunet.at> writes
Quote
>Patricia Handwerk schrieb:

>> Sure you post your homework assignment without even attempting to do
>> it yourself.  And to top it all off you post in a Pascal group and > program
>to do in C.

>The whole question does not seem meaningful. What he is searching
>for, is a fully fledged string parser - not a typical homework
>assignment for beginners. Regardless of the language C or Pascal.

I reread it myself just now. Its certainly no introduction to a language
as the full parser requires some work especially to include precedence
as well as () pairs.

Funny thing is, I seemed to remember something from "way back when" that
I got given ...[looks]... ALGOLW on an IBM360 ... sounds rather similar
... end of 1st year at University.

Methinks we have a "couldn't be bothered to do the class(es)" and is
trying to dress it up.

--
Pedt Scragg

No-one is completely useless, they can always be a bad example.

Other Threads