Write down a not so bad cardiac simulator

Assignment Help Computer Engineering
Reference no: EM1331503

Write a not so bad CARDIAC simulator (in C++) that tells the user how to execute an instruction typed as a 3 digit number by the user.

The user should be prompted to type in a 3 digit number, and then the program should print to the screen whatever the CARDIAC Instruction Decoder box would show had that been the instruction.

* Use a pleasant switch statement for decoding the instructions based on op-codes, rather than nested if, consecutive if, or if/elseif monstrosity.

* Use a loop to allow users to provide as many instructions as they would like. Inform the users what they could type to exit the program (e.g., entering "1234" as an instruction).

* Keep track of the accumulator for the user. Use an accumulator variable for this purpose.

Assume that the accumulator contains 0 when the program starts. If the instruction modifies the accumulator (i.e., instructions 1xx, 2xx, 4xx, and 7xx), prompt the user for whatever data is necessary to execute the instruction, and execute
it ensuring that the accumulator is modified appropriately. Do not forget that the accumulator is only 3 digits long.

* Instruction 6xx should replace the word "accumulator" with the current value of the accumulator in its output to the user.

An example run of program might look like this.

Enter a 3 digit CARDIAC instruction (negative to exit): 123
Replace accumulator with cell 23
Enter the data in cell 23: 431
Enter a 3 digit CARDIAC instruction (negative to exit): 412
Shift accumulator left 1 digits, then right 2 digits
The accumulator now contains 3
Enter a 3 digit CARDIAC instruction (negative to exit): 375
Move bug to cell 75
Enter a 3 digit CARDIAC instruction (negative to exit): 250
Add the contents of cell 50 to the accumulator
Enter the data in cell 50: 99
Enter a 3 digit CARDIAC instruction (negative to exit): 348
Enter a 3 digit CARDIAC instruction (negative to exit): 630
Copy accumulator to cell 30
The accumulator now contains 96
Enter a 3 digit CARDIAC instruction (negative to exit): -1

Operation codes are as follows:

Code Abbreviation Meaning
0 INP Copy input to memory.
1 CLA Copy memory to accumulator.
2 ADD Add memory to accumulator.
3 TAC Move bug if accumulator < 0.
4 SFT Shift accumulator left then right.
5 OUT Copy memory to output.
6 STO Copy accumulator to memory.
7 SUB Subtract memory from accumulator.
8 JMP Backup bug to 99 then move bug.
9 HRS move bug and stop computing.

Reference no: EM1331503

Questions Cloud

Write down the worst cardiac simulator of all time : make the worst CARDIAC simulator of all time (in C++) that tells the user how to execute only a single instruction typed as a 3 digit number by the user.
Zero sampling risk : Besides the medical and environmental field what other testing issues do we demand 100% accuracy on (zero sampling risk)?
Explaining cross-cultural motivational leadership : Is Hofstede's cultural dimensions model an adequate and thorough paradigm for cross-cultural motivational leadership?
Explain how the below game should be set-up : Explain how the below game should be set-up, played and solved a consumer decide.
Write down a not so bad cardiac simulator : The user has to be prompted to type in a 3 digit number, and then the program should print to the screen whatever the CARDIAC Instruction Decoder box would show had that been the instruction.
Evaluating strategy : Identify the types of organizations that may need to evaluate strategy more frequently than others.
Incremental cash flows : Discuss qualitatively how you might have incorporated the likely growth of digital photography in the sales projections developed above?  (Remember hindsight is 20-20.)
How we can implement a cardiac machine simulator in c++ : Keep track of the bug location; which could be an index into the memory array. Watch out for cells 0 and 99; they are special. Read the input tape from a file that starts with a number telling you how various items are on the tape.
Explaining individualism and collectivism affectivity : Define the following relationships: Individualism v collectivism affectivity

Reviews

Write a Review

Computer Engineering Questions & Answers

  Define why it is suggested that for security reasons

Since many commercial APs have the SSID broadcast option enabled by default, so clients may easily detect the presence of an AP. APs are also configured as DHCPs and Firewalls.

  Developing uml one state diagram

How the system responds to the external and/or internal events by developing a UML ONE State Diagram.

  Storyboards-interactivity diagram-object dicitionary

Develop the storyboards, interactivity diagram, object dicitionary, and any essential scripts for an interactive program for the customers of Sunflower Floral Designs.

  Suppose a station ti takes 2 hours to change horses

suppose that at a station ti takes 2 hours to change horses and a horse takes (x ln x)/100 hours to travel x miles. plan a dynamic programming algorithm to determine a sequence of stations at which to stop so as to minimize the total hours.

  Birt is an open source eclipse-based reporting system

BIRT is an open source Eclipse-based reporting system that integrates with your Java/J2EE application to produce compelling reports BIRT provides core reporting features as in report layout, data access and scripting.

  Describing the penetration test

By using the MS Word, write down the three-page summary explaining a successful penetration test. Which penetration tools and techniques do you think would be required in the successful penetration test.

  Using access qbe or sql

Using the Access QBE or SQL, produce and run the view-equivalent queries to answer the questions that follow.

  What stages of computation does garbage collection

For a list with n Nodes, what is the maximum number of nodes that are "live" (i.e., accessible from a "root set" of variables) during the method inverse(), and when does this atmost occur.

  Write a function that creates a cell and structure array

Write a function that creates a cell and structure array.

  Analyze running time of algorithm

Analyze running time of algorithm

  Consider database security from a variety of perspectives

Share experiences have you had in terms of user security in past jobs or as a student? Do you feel the user security was effective in those situations? What will you have done differently in light of what you've learned about data security.

  What steps will you take to analyze the problem?

You are working on a new computer game. One of implementation problems you are trying to solve is character path finding. The user should be able to select a character and left-click the mouse at a location to have the character move to that new l..

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