Write a program called a2p1 to run in the lc-3 simulator

Assignment Help Computer Engineering
Reference no: EM13324724

Part I!

Write a program called A2P1 to run in the LC-3 simulator. The program asks for the user to type in his or her UPI. Then the program asks for the age of the user and prints the UPI out that many times. Here is an example of input and what should be produced in the simulator's console window.!

For Part I you may assume (in fact you must assume) that the input provided will always match what is expected. i.e. do not consider what would happen if the user makes a mistake entering data. !

The program should work exactly like this:!

The program displays "Enter your upi: ".!

It then waits until the user has typed 7 characters (these get stored by the program).!

The characters typed by the user are shown on the console as the user types them.!

After the 7th character the console output goes to the next line automatically without the user having to type return/enter and displays

"Enter your age: " !

It then waits until the user has typed a number (you may assume it will always be between 0 and 999) and has pressed return/enter.!

Once again the characters typed by the user are shown (echoed) on the console as the user types them.!

Then the program prints the upi the same number of times as the user's entered age. Each upi appears on a separate line.!

Then the program halts.!

Part II!

This program should be called A2P2. This part is very similar to Part I, however you have no guarantees about the accuracy of the input from the user. You have to check all input and give  helpful error messages to assist the user. In particular you must ensure that the user does not enter more data than your program is able to safely accept, i.e. you must prevent buffer over?ows. If the user enters valid input then the program should behave exactly as the program in Part I with the exception that the user has to press return/enter after typing in his or her UPI.!

You also have to include a function in your program named promptInput which is called twice (using JSR). The promptInput function takes three parameters:!

1. the address of the prompt string e.g. "Enter your upi: "!

2. the address of the buffer to hold the typed input!

3. the length of the buffer (this will have to be 1 more word than the expected maximum number of characters the user will type), why?!

The function should return a value of 0 to its calling context if the input ?ts in the buffer or -1 if the user types in too many characters.!
As soon as the user types more characters than can ?t in the buffer your program should respond with the message "You have entered too many characters, you must start again." This message appears without the user having to type return/enter. It appears on a new line and after this the program once again prompts the user either for a UPI or an age (depending on what the user was doing at the time of the buffer over?ow).!

Once the UPI has been entered in the promptInput function it then needs to be checked for validity. A valid UPI for this assignment consists of 4 lowercase alphabetical characters followed by 3 digits. If an invalid UPI is typed the program responds with the message "Invalid upi. Try again." on a new line. Then the program asks "Enter your upi: " again and the program continues.!

Similarly the age needs to be checked for validity. Valid ages are any value from 0 to 999 (ok not very realistic). Only digits are valid e.g. if the user enters "_23" with the ?rst character being a space this should be rejected. If an invalid age is typed the program responds with the message "Invalid age. Try again." on a new line. Then the programs asks "Enter your age: "again and the program continues.!

Reference no: EM13324724

Questions Cloud

Case-assessing procter and gamble acquisition of gillette : What kind of M&A event is the story describing? (Is a horizontal/vertical merger, consolidation, or other kind of event?) How do you know? Be sure to justify your response.
How far was the car from the dog : A certain cable car is San Francisco can stop in 10 s when traveling at maximum speed. how far was the car from the dog
Explain the concentration (mol/l) of co(g) : When CO(g) (9.035 mol) and 144.6 grams of O2(g) in a 220.0 L reaction vessel at 608.0 °C are allowed to come to equilibrium the mixture contains 0.02021 mol/L of CO2(g). What is the concentration (mol/L) of CO(g)? 2CO(g)+O2(g) = 2CO2(g)
What is the importance of marketing implementation : What is the importance of marketing implementation? How might a company have excellent planning and poor implementation?
Write a program called a2p1 to run in the lc-3 simulator : Write a program called A2P1 to run in the LC-3 simulator. The program asks for the user to type in his or her UPI. Then the program asks for the age of the user and prints the UPI out that many times.
How many excess electrons does a typical red blood cell have : A red blood cell typically carries an excess charge of about -2.5 × 10-12 C distributed uniformly over its surface. How many excess electrons does a typical red blood cell have
Explain a dark-red liquid calcium : match each of the elements on the right with he description on the left a) a dark-red liquid calcium (ca) b)a colorless gas the burns in oxygen gas gold (au) c) a metal that reacts violently with water hydrogen(H2)
The colin powell paper : The Colin Powell paper.
Oty cosmetics integrates unilever cosmetics international : What kind of M and A event is the story describing and part of the M&A event required both companies to divest assets. Why would a government regulator force them to divest certain assets as to approve an M&A event?

Reviews

Write a Review

Computer Engineering Questions & Answers

  Windows live id and skydrive account

Suppose there are 1 million books within your campus library. Approximate (to the nearest order of magnitude) how several bytes of the data there are in case all these books were stored online and accessible across the computer network.

  Decribe the functions of a network node manager

Explain the processes that take place during network discovery and mapping.

  Recall extensive change that have witnessed

Try to generalize your observations so they can serve as a guideline for similar cases.

  Draft the testing procedures to be used by groover

Draft the testing procedures to be used by Groover Consulting whenever they provide software to their clients. The procedures will be used by Groover Consulting to that the software they are delivering is reliable, accurate, and fault tolerant.

  Give the average frame replacements for each

you would create a program that automatically generates numbers between a range provided by the user and stores them in an array. Your program will then calculate the number of page faults using replacement algorithms and provide the average frame..

  Design and implement a class called monetarycoin

Design and implement a class called MonetaryCoin that is derived from the Coin class presented in Chapter 5. Store an integer in the MonetaryCoin that represents its value and add a method that returns its value.

  Encipher a message using a keyword

The first program will encipher a message using a keyword and second program will decipher a message using a keyword.

  Explain the method to create a scheme for vb mail order

Explain the method to create a scheme for VB Mail Order

  Design a heat exchanger for the following duty

Fix a tentative geometry and perform all standard calculations and verify the adequacy of your proposed design in terms of operating parameters

  Ssl protection

Explain whether pages are served over the SSL protected from problem you explained. If so, explain why; if not, explain why not.

  Change in behavior that occurs as a result of experience

Give an instance of such a "lesson" that helped you to improve your job performance. Try to generalize this isolated experience of yours into a "training method" that would help others to improve their performance as well.

  Variables reduce unnecessary comparision in a bubble sort

when merging 2 files, what condition terminates the main loop of the program.What type of variables can be used to reduce unnecessary comparision in a bubble sort.

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