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

  Write a program that generates a random integer

Write a program that generates a random integer in the (inclusive) range [0-9] (i.e. the set {0,1,2,3,4,5,6,7,8,9}) and ask the user to guess what the number is .

  Why information security is not factor for organization

But would not require to give for information security on those systems. Explain that environment and desribe why information security is not factor for that organization.

  Describe how to develop users for sales organization unit

Describe how you would develop users for sales organization unit and how you can set up work groups in this particular situation.

  True or false on computer science

True or False 1. If a computer uses hardwired control, the microprogram determines the instruction set for the machine.

  Write a script to help users calculate compressed file size

Develop a small console program driven by a text menu (see the sample screenshot below):? It displays a simple menu with 4 items indicated by number 1-4.? Users will enter number 1 to 4 to run some commands.?

  Deliver software to a schedule

You are asked by your manager to deliver software to a schedule that you know can only be met by asking your project team to work unpaid overtime.

  What decimal number would the ieee 754

What decimal number would the IEEE 754 single precision floating point number 0xCAE80000 (this is in hex) be? Write your final answer in scientific notation as m x 10 p where p is an integer.

  Research methods to explain connectivity needs star clothing

Research the alternatives to address the connectivity needs for Star Clothing, and make a recommendation that includes the following.

  Define static binding and dynamic binding

1. Define static binding and dynamic binding and give an example of each. Static binding occurs at compile time and dynamic binding occurs at run time. 2. Describe a situation when a history sensitive variable in a subprogram is useful.

  Explaining set of all regular languages is countable

Prove or disprove: the set of all regular languages is countable.

  Create a change - counting game

create a change - counting game that gets the user to enter the number of coins required to make exactly one dollar. the program should let the user enter the number of pennies,nickels,dimes, and quarters.

  Explaining open-source software products like linux

Intellectual property as well as increase its support of open-source software products like Linux be a successful growth strategy in the "brutally competitive marketplace" in which it operates? Why or why not?

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