Skip to main content
留学咨询

辅导案例-COMP 335

By May 15, 2020No Comments

COMP 335 Programming Languages Fall 2019 Project PL5 Due Date: December 6 Purpose You will use Haskell to write a calculator simulator. This is super-fun! This is an individual project. Problem With scientific/graphing calculators, one can type in complicated calculations all on one line. The calculator computes the answer using normal mathematical precedence rules. You are to write a program in Haskell that will simulate a calculator that can handle mathematical operators with floating point operands. Input The input will be a one line calculation such as the following: 5 + 3.3 ∗ 8− 9 = The expression is in infix order and may be any length. Valid operators are +, −, /, ∗, and ˆ (exponentiation). Each number can be any floating point value. There are no spaces in between any individual items of the input. The equal sign signifies the end of the expression. NO parentheses may be input. You may assume that the input will be typed in correctly, so no error checking is necessary. Output The program should display, simply, the answer (!) of the calculation on the screen. Specifics • Computations must be done in order of precedence. For this assignment, ˆ has the highest precedence, followed by ∗, / (same precedence), and finally +,−. Multiple operators with the same precedence are handled in left-to-right order. • Stacks must be used to determine the answer. These will work similar to the example in the text and what was shown in class. • Include an introductory comment with your name, description, input, and output. Also write a short comment for each function. Notes • Although this program is not very long, do not underestimate the time this may take. You are (probably) not an expert Haskell coder, so take it slow and be sure you understand your own code. • Submit your source code via email with the usual naming conventions, as in gousiePL5.hs. Hand in a hard copy version of your program in the envelope on my door by 5:00 PM on Monday, 12/9. The answer is either m or something else. – Eva Ma, one of my grad school professors

admin

Author admin

More posts by admin