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

  Draw a flow chart, hierarchy chart

Draw a flow chart, hierarchy chart, and write pseudocode for the following problem. • A weather sensing system calculates & prints a report on the following: ? Average temperature ? Highest temperature ? Lowest temperature ?

  List and describe three guidelines for sound policy

List and describe briefly the three guidelines for sound policy, as stated by Bergeron and Bérubé. Are policies different from standards? In what way? Are policies different from procedures? In what way?

  What does it mean to spawn a process?

1. Process can be in different states to allocate the resources better. List the symbol and meaning for each of these states

  Create direct-mapped data cache for the byte offset

Create the 128KB direct-mapped data cache which uses a 32 bit address and 16 bytes per block. Compute the following: How many bits are utilized for the byte offset?

  What is the number of significant decimal digits

the 36 bit computer uses the 28 bit mantissa and the 8 bit exponent. what is the number of significant decimal digits and what is the range of real numbers for this machine?

  Describe the syntax of programming languages

Please provide an example of where and how BNF might be used to solve real-world problems (by this I mean problems outside the languages and compiling domain). Please be specific and provide an example.

  Use mcnaughton''s wrap around rule

Use McNaughton's wrap around rule to construct a preemptive

  What is the total password population

A phonetic password generator picks two segments randomly for each six-letter password. the form of each segment is consonant, voul, consonant, where V= and C= (V)

  Apply the cartesian product construction

Apply the Cartesian product construction to (i) and (j) to obtain an automata recognizing the union of their languages. i. {w|w every odd position of w is a 1} j. {w| w contains at least two Os and at most one 1}

  How large video memory is required to store image

How large a video memory is required to store a 640 X 480 image during display? A 1600 X 900 image? A 1440 X 1080 image?

  Create a 64mb encrypted file system

Write an instruction sheet for the user so that she can make the modi cations to her home machine so that she can access the le on the ash drive containing the encrypted le system.

  Write a program with three radio buttons

Write a program with three radio buttons and circle. ( You can choose whether you draw the circle or if the circle is a label image.) When the user clicks on the first radio button

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