You have no guarantees about the accuracy of the input from

Assignment Help Application Programming
Reference no: EM13380342

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: EM13380342

Questions Cloud

Given the following sample database diagram do the : given the following sample database diagram do the followingcreate the needed tables in the sql server environment just
Part 1in your own words answer the following questionswhat : part 1in your own words answer the following questionswhat is network infrastructure management? what are the
Project 1 bull in your own words what rfc gives : project 1 bull in your own words what rfc gives the protocol and specifications a news server must use to
The australian commonwealth government has developed a : the australian commonwealth government has developed a cloud computing strategy and cloud computing policy and you as
You have no guarantees about the accuracy of the input from : you have no guarantees about the accuracy of the input from the user. you have to check all input and give helpful
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
Part 1 you will implement a program where the computer : part 1 you will implement a program where the computer plays against a human opponent. the game will start with a
Proceed according to the following instructionsidentify a : proceed according to the following instructions.identify a recent within the last six 6 months moral dilemma or
Consider the relational schema of part of a firm database : consider the relational schema of part of a firm database below. write a sql query for each of the following

Reviews

Write a Review

Application Programming Questions & Answers

  In this lab we will use the uart0 peripheral to communicate

in this lab we will use the uart0 peripheral to communicate with a pc using the rs232c serial protocol. we will

  In this project you will create an application to run in

in this project you will create an application to run in the amazon ec2 service and you will also create a client that

  Write a c program that displays a table showing the price

write a c program that displays a table showing the price of silver and gold. the table will have three columns. the

  Problem build a class for a type called fractionnbspthis

problem build a class for a type called fraction.nbspthis class is used to show a ration of two integers.nbsp include

  One of the problems of storing data in a matrix a

one of the problems of storing data in a matrix a two-dimensional cartesian structure is that if not all of the

  Consider the above diagram figure of the car park the

consider the above diagram figure of the car park. the object of this assignment is to write a program to operate the

  Write a paper on mcdonaldsethics and social responsibility

write a paper on mcdonalds.ethics and social responsibility at mcdonaldspaper includesabout mcdonaldscorporate social

  Question 1a write an assembly code segment that calls the

question 1a write an assembly code segment that calls the subroutinenew functionif bits 5 and 6 of portd equal 1.b

  Problemthe manager of the super supermarket would like to

problemthe manager of the super supermarket would like to be able to compute the unit price for products sold there. to

  Create a multi-threaded competition in which opposing robin

create a multi-threaded competition in which opposing robin hoods will attack one another and try to take each others

  1 which of the following is not true with regards to

1. which of the following is not true with regards to thefollowing statement?namejohndoeampserial123456ampsystemma.

  Regional gardens ltd is a company that runs a number of

regional gardens ltd is a company that runs a number of related gardening enterprises. it has a large display garden

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