Write a calculator program that is able to process an input

Assignment Help Basic Computer Science
Reference no: EM13219886

Write a calculator program that is able to process an input in postfix notation and give the result. You are free to use the built in stack class or create your own ones. Your program should be able to detect the invalid postfix input and report "invalid", if the input is valid your program should output the correct result. For your convenience, you may suppose the input consists only positive integers and the operators are only +,-,*,/. But during the process, the results can be negative, for example "4 6 -" is allowed. The first line of the input contains K the number of cases, the next K lines each contains a string of postfix notation. You will be asked to read the input from "a5input.txt". The output should be either the result of a valid string or "invalid" if the string is not in postfix notation. Sample Input: 4 7 8 9 + * 4 6 - * 3 4 + 5 6 + * 3 4 5 * + 2 3 + - 5 7 * Sample Output: -238 77 23 invalid

Reference no: EM13219886

Questions Cloud

What is the peak achievable performance : Consider a memory system with a level 1 cache of 32 KB and DRAM of 512 MB with the processor operating at 1 GHz. The latency to L1 cache is one cycle and the latency to DRAM is 100 cycles.
Calculate the minimal sum logic for each output : How would I do this problem? When it says 4-bit two's complement numbers, what does it mean?
What is the after tax initial investment in the defender : current asset (defender) is being evaluated for potential replacement. It was purchased four years ago at a cost of $62,000. It has been depreciated as a MACRS (GDS) five-year property- class asset. The present MV of the defender is $12,000.
Explain the same heat capacities as pure water : Determine q for the acid-base reaction, assuming that the liquids have densities of 1.00 g/mL and the same heat capacities as pure water.
Write a calculator program that is able to process an input : Write a calculator program that is able to process an input in postfix notation and give the result. You are free to use the built in stack class or create your own ones.
Should commodity be purchased in the uk or in us : A certain commodity cost 0.5 pound sterling in the United Kingdom. In U.S. denominated dollars, this same item can be purchased for 85 cents. The exchange rate is 1 pound sterling= $1.80 U.S. a. Should this commodity be purchased in the United King..
Compute the volumetric size of a water : Calculate the volumetric size of a water molecule in vapor, assuming 1 mole of the vapor occupies 22.4 L, as if the vapor were an ideal gas.
What is the estimated exchange rate two years from now : An international corporation located in Country A is considering a project in the United States. The currency in Country A, say X, has been strengthening relative to the U.S. dollar; specifically, the average devaluation of the U.S. dollar has bee..
Explain what volume in ml of concentrated nitric acid : What volume in mL of concentrated nitric acid (72.0% HNO3 (w/w), sp. gr. 1.42) is required to prepare exactly 2.00 L of 0.200 M HNO3?

Reviews

Write a Review

Basic Computer Science Questions & Answers

  Identifies the cost of computer

identifies the cost of computer components to configure a computer system (including all peripheral devices where needed) for use in one of the following four situations:

  Input devices

Compare how the gestures data is generated and represented for interpretation in each of the following input devices. In your comparison, consider the data formats (radio waves, electrical signal, sound, etc.), device drivers, operating systems suppo..

  Cores on computer systems

Assignment : Cores on Computer Systems:  Differentiate between multiprocessor systems and many-core systems in terms of power efficiency, cost benefit analysis, instructions processing efficiency, and packaging form factors.

  Prepare an annual budget in an excel spreadsheet

Prepare working solutions in Excel that will manage the annual budget

  Write a research paper in relation to a software design

Research paper in relation to a Software Design related topic

  Describe the forest, domain, ou, and trust configuration

Describe the forest, domain, OU, and trust configuration for Bluesky. Include a chart or diagram of the current configuration. Currently Bluesky has a single domain and default OU structure.

  Construct a truth table for the boolean expression

Construct a truth table for the Boolean expressions ABC + A'B'C' ABC + AB'C' + A'B'C' A(BC' + B'C)

  Evaluate the cost of materials

Evaluate the cost of materials

  The marie simulator

Depending on how comfortable you are with using the MARIE simulator after reading

  What is the main advantage of using master pages

What is the main advantage of using master pages. Explain the purpose and advantage of using styles.

  Describe the three fundamental models of distributed systems

Explain the two approaches to packet delivery by the network layer in Distributed Systems. Describe the three fundamental models of Distributed Systems

  Distinguish between caching and buffering

Distinguish between caching and buffering The failure model defines the ways in which failure may occur in order to provide an understanding of the effects of failure. Give one type of failure with a brief description of the failure

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd