MTRX1702 Lecture 2: MTRX1702, lec 2 Assignment 2-Calculator

117 views4 pages

Document Summary

You are required to write a program that calculates and displays the result of arbitrary mathematical expressions entered by the user: when the program is run, it is to display a short welcome message. Simple calculator: the program shall display a simple prompt waiting for user input, the following help message shall be displayed whenever the user types the letter h at the input prompt. / division: the program shall exit if the user types the letter q at the input prompt. Before exiting it should print the following message: Error: illegal input: on detection of divide-by-zero, the following error message shall be displayed: This means that rules are required for precedence of operators as infix notation can be ambiguous. If you convert the input string to postfix notation there is no ambiguity and evaluating the expression becomes a series of stack operations.

Get access

Grade+20% off
$8 USD/m$10 USD/m
Billed $96 USD annually
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
40 Verified Answers
Class+
$8 USD/m
Billed $96 USD annually
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
30 Verified Answers

Related Documents