Skip to content

Fuma078/Programming-Assignment-3-ADT

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 

Repository files navigation

Programming-Assignment-3-ADT

Assignment-3-ADT: Programming Assignment 3 in ADT & Solving Problem course that processes an input file to convert an infix mathematical expression into its equivalent postfix notation using a stack-based approach, ensuring correct operator precedence and handling parentheses.

Description

This program converts an infix mathematical expression into its equivalent postfix notation using a stack-based approach. It reads the infix expression from a file (input1.txt), processes each character, and correctly applies operator precedence and associativity rules to generate the corresponding postfix expression. The program ensures proper handling of parentheses and detects any invalid expressions.

Installation

  1. Ensure you have Java installed on your system.
  2. Download or copy the InfixToPostfix.java file.
  3. Create an input1.txt file in the same directory and insert a valid infix expression.
  4. Compile the program using:
    javac InfixToPostfix.java
  5. Run the program:
    java InfixToPostfix

Usage

  • The program reads an infix expression from input1.txt.
  • It validates the expression, ensuring correct use of operators and parentheses.
  • It converts the infix expression to postfix notation using a stack-based approach.
  • The converted postfix expression is displayed on the console.

Features

  • Operator Handling: Supports +, -, *, /, and ^ operators.
  • Parentheses Support: Correctly processes expressions with ( and ).
  • Error Handling: Detects invalid characters and mismatched parentheses.
  • File Input: Reads expressions from an external file.
  • Stack-Based Processing: Efficient conversion using a stack for operators.
  • User-Friendly Output: Displays both the input infix expression and the resulting postfix expression.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages