Your job is to provide an implementation for a module and a class whose interface is predefined. We are building a postfix calculator called Calc. For details about postfix notation, see Section 14.10 in your textbook (p XXXXXXXXXXYou have been provided with a driver in the form of a main function with a while loop in it. In addition, there is a module called input that contains a couple of routines for validating input. You must implement the routines in the input module. You will find prototypes in input.hpp.

In order to implement postfix notation, you need a stack. You are provided with an interface for a Stack class that uses the vector class from the Standard Template Library (See Chapter 8 in your textbook). You must implement the Stack class according to the class declaration provided in Stack.hpp.

You must hand in two files: one called input.cpp and one called Stack.cpp. The input.cpp file should contain an implementation of the function prototypes in input.hpp. The Stack.cpp file should contain an implementation of the class declared in the Stack.hpp file.

Your implementation must match the interface exactly. I will drop them into a project directory with my own header files and main program, and they should work without modification.

The Program:

The Calc program is a command-line calculator. When you run it, it shows you a prompt, which is a dollar sign ($). You can type numbers, and you can type mathematical operators. There are five operators: +, -, *, /, and % for add, subtract, multiply, divide, and modulus, respectively. All operators are integer only.

Numbers may be preceded by an optional ‘+’ or ‘-’, followed by one or more digits. This calculator operates on integers only. When you enter a number, it is placed on the stack.

When you enter an operator, the program applies the operator to the top two numbers on the stack. If there are not enough numbers, the program prints an error message. If the operation is successful, the result is printed to the console. The result also remains on the stack top.

You can type ‘p’ to print out the current stack contents. You can type ‘x’ to exit the program.

All other input produces an error message.

Answered Same DayDec 08, 2021

Calc/input.cpp

#include "input.hpp"

#includeusing namespace std;

ool is_a_binary_operator(std::string inputValue, char& op)

{

int i, f = 0;

for (i = 0; inputValue[i] != '\0' && f == 0; i++)

{

if (inputValue[i] == '+' || inputValue[i] == '-' || inputValue[i] == '*' || inputValue[i] == '/' || inputValue[i] == '%')

{

op = inputValue[i];

f = 1;

}

}

return f;

}

ool is_a_number(std::string inputValue, int& x)

{

int i, f = 0, num=0;

for (i = 0; inputValue[i] != '\0'; i++)

{

if (isdigit(inputValue[i]))

{

num = num * 10 + inputValue[i] - '0';

x = num;

f = 1;

}

}

return f;

}

Calc/input.hpp

#ifndef INPUT_HPP

#define INPUT_HPP

#include --------------------------------------------------------------------

Function: is_a_binary_operato

Description: Reads a mathematical operator from a string.

Operators recognized: +, -, *, /, %

If successful, the operator is returned in

the `op' reference parameter.

Parameters: inputValue : string

op : char&

Returns: true if a binary operator was found, and false

otherwise

--------------------------------------------------------------------

ool is_a_binary_operator(std::string inputValue, char&...

#include "input.hpp"

#include

ool is_a_binary_operator(std::string inputValue, char& op)

{

int i, f = 0;

for (i = 0; inputValue[i] != '\0' && f == 0; i++)

{

if (inputValue[i] == '+' || inputValue[i] == '-' || inputValue[i] == '*' || inputValue[i] == '/' || inputValue[i] == '%')

{

op = inputValue[i];

f = 1;

}

}

return f;

}

ool is_a_number(std::string inputValue, int& x)

{

int i, f = 0, num=0;

for (i = 0; inputValue[i] != '\0'; i++)

{

if (isdigit(inputValue[i]))

{

num = num * 10 + inputValue[i] - '0';

x = num;

f = 1;

}

}

return f;

}

Calc/input.hpp

#ifndef INPUT_HPP

#define INPUT_HPP

#include

Function: is_a_binary_operato

Description: Reads a mathematical operator from a string.

Operators recognized: +, -, *, /, %

If successful, the operator is returned in

the `op' reference parameter.

Parameters: inputValue : string

op : char&

Returns: true if a binary operator was found, and false

otherwise

--------------------------------------------------------------------

ool is_a_binary_operator(std::string inputValue, char&...

SOLUTION.PDF## Answer To This Question Is Available To Download

- COP3502C Computer Science 1 Dr. Andrew Steinberg Spring 2022 Programming Assignment 3 The Card Game of War Max Points 100 Due: 3/14/2022 at 11:59pm Background Story of this Assignment You have just...SolvedMar 14, 2022
- Write a functional C program that meets the following: This program should use at least one of each the following: for loop(s) while loop(s) do while(s) if else construct(s) switch statement(s)...SolvedMar 13, 2022
- lab assigments 1. W rite a program that inputs FRO M THE U SER the values of three Boolean variables cin operator from the eight Possible cases used in the previous dem o w hich are in the text Table...SolvedMar 11, 2022
- // This is the pseudocode for an ‘iterative’ binary search procedure CSC 219: Programing in C Lab 6 20 Points Using recursive functions and arrays You are to write two recursive functions in C and a...SolvedMar 10, 2022
- // This is the pseudocode for an ‘iterative’ binary search procedure CSC 219: Programing in C Lab 5 Using arrays and pointers to manipulate strings In this lab you will implement 4 string functions,...SolvedMar 10, 2022
- lab assigments LAB #3! SEE YO U R G RO U P VERSIO N . READ CAREFU LLY W H AT IS W AN TED !. Be sure each num bered task is done. N ote due date from class, , Em ail subject G #-lab3 V x x y V y 1. int...SolvedMar 05, 2022
- CS 280 Fall 2021 Recitation Assignment 6 March 3rd, 2022 Due Date: Monday, March 7, 2022, 23:59 Total Points: 5 Write a recursive C++ function, called PrintRevNums, that reads a positive integer...SolvedMar 01, 2022
- Page 1 of 1 File Input Assignment Assignment objective: Begin implementing a lexical analyzer by first writing the code to read from a text file one line at a time and printing each line one character...SolvedMar 01, 2022
- Lab3.dvi McMaster University Dept. Electrical and Comp. Engineering COE 2SI3 - Term II (Winter) 2022 Lab 3 - Implementation of Polynomial Using Linked List Due Date: Lab sessions February 28 – March...SolvedFeb 28, 2022
- HW2 CS240 - Programming in C HOMEWORK 2 ——————————————————————————————————————————————————————————————————————————————— Write a C program to implement the following requirement: Input: The program...SolvedFeb 24, 2022

Copy and Paste Your Assignment Here

Disclaimer: The reference papers provided by TAE serve as model papers for students and are not to be submitted as it is. These papers are intended to be used for research and reference purposes only.

Copyright © 2022. All rights reserved.