Programming Assignment 4 for CSC3410: Infix to Postfix Expression Conversion, Assignments of Data Structures and Algorithms

A programming assignment for csc3410 students, due on march 9th, 2009. The objective is to write a program that converts infix expressions to postfix expressions. The program should accept strings of infix expressions with spaces, parentheses, and the operators +, -, *, /. The output should be the postfix expression, with spaces optional. Optional features include handling real numbers and reporting errors.

Typology: Assignments

Pre 2010

Uploaded on 08/31/2009

koofers-user-wtg-1
koofers-user-wtg-1 🇺🇸

10 documents

1 / 1

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Programming Assignment 4 – CSC3410
Due date: March 9th , 2009
Objective: This assignment is a review for Chapter 7(Stack).
All the programs source code and the output screens must be submitted
together. A hardcopy of these files are due in class on the due date and
students also have to submit their source code files and the executable file
as attachments by email or qubit.cs.gsu.edu before the due date.
1. Write a program that allows user to input a string of infix expression,
and output the postfix expression on screen. You can assume the
infix expression is syntax correct and only four types of operators (+,
-, *, /) and the parenthesis ( ), ( ) exist. The operand might be a string
or integer number. Spaces should also be allowed in the input. For
example, your program should accept the following forms:
a - (b + c * d)/e // output: abcd*+e/-
a + b - 20 //output: ab20-+
(gallons * price) / miles //output: gallons price * miles /
Your output is printing the correct postfix expression and spaces can
be eliminated or kept.
2. Optional: allow real number in the input; allow errors in the input
and report these errors. For example,
(apple *4.5) / 5.3 //correct
2.5 – (10 * egg) //correct
10 a - c / d // wrong, report it
(a + c) * e ) // wrong, report it
-2 + 4 //wrong, report it
4 * a4 //wrong, report it

Partial preview of the text

Download Programming Assignment 4 for CSC3410: Infix to Postfix Expression Conversion and more Assignments Data Structures and Algorithms in PDF only on Docsity!

Programming Assignment 4 – CSC

Due date: March 9th^ , 2009 Objective: This assignment is a review for Chapter 7(Stack). All the programs source code and the output screens must be submitted together. A hardcopy of these files are due in class on the due date and students also have to submit their source code files and the executable file as attachments by email or qubit.cs.gsu.edu before the due date.

  1. Write a program that allows user to input a string of infix expression, and output the postfix expression on screen. You can assume the infix expression is syntax correct and only four types of operators ( + , - , ***** , / ) and the parenthesis ( ) , ( ) exist. The operand might be a string or integer number. Spaces should also be allowed in the input. For example, your program should accept the following forms: a - ( b + c * d )/ e // output: abcd*+e/- a + b - 20 //output: ab20-+ (gallons * price) / miles //output: gallons price * miles / Your output is printing the correct postfix expression and spaces can be eliminated or kept.
  2. Optional: allow real number in the input; allow errors in the input and report these errors. For example, (apple *4.5) / 5.3 //correct 2.5 – (10 * egg) //correct 10 a - c / d // wrong, report it (a + c) * e ) // wrong, report it -2 + 4 //wrong, report it 4 * a4 //wrong, report it