Prompt input function

Assignment Help Programming Languages
Reference no: EM13192480

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

Questions Cloud

What is the probability of producing bad product : The diameter of a mason jar is 3 inches but can be as large as 3.03 inches and as small as 2.97 inches. Twenty five samples of mason jars are taken and it is discovered that these components have a grand mean of 3.01 inches and a standard deviatio..
Demanded : Using the word "demanded" instead of the word "pleaded" when you mean to show force of action is a matter of word
Explain the importance of euclid''s parallel postulate : Explain the importance of Euclid's parallel postulate in the development of hyperbolic and spherical geometry.
What is the marginal propensity to consume : Income Savings I(planned) Consumption 200 -20 60 400 0 60 600 20 60 800 40 60 1000 60 60 1. Fill in the last  column. 2. The equilibrium level of income in this example is  3. According to this data, the marginal propensity to consume is .
Prompt input function : 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.
State calcium carbonate would be needed to neutralize : Chlorine reacts with water to produce hydrochloric acid. Suppose 2.5 kg of chlorine were added to an olympic-sized swimming pool. How many grams of calcium carbonate would be needed to neutralize
What is the surface area of a rectangular prism : what is the surface area of a rectangular prism its 10ft long and 6ft wight and 8ft tall?
Transportation-food and lodging : The three major expenses for people traveling abroad are transportation, food, and lodging" is an example of an effective specific purpose statement for a speech.
Sketch all the nonisomorphic, simple graphs : Sketch all the nonisomorphic, simple graphs that have 5 vertices and 5 edges.

Reviews

Write a Review

Programming Languages Questions & Answers

  Design a website to allow calculation of areas

Design a website to permit calculation of areas. A radio button list can be used to allow the user select what type of area to be calculated. Once the selection is done, the input text boxes should be displayed with the proper labels.

  Program to compute pearson correlation coefficient

Write down a program to compute Pearson correlation coefficient by using parallel loop templates from Intel Threading Building Blocks library (TBB).

  Write down public static method using public interface

Using only public interface of UnorderedLinkedList class, write down a method: public static void reverse(UnorderedLinkedList staff) that reverses the entries in a linked list.

  Write program which prompts user for interger value

Write a program which prompts user for interger value in range 0 to 32,767 and then prints infividual digits of numbers on line with three spaces between digits.

  Write script which declares and sets variable

Write the script which declares and sets a variable that's equal to total outstanding balance due. If that balance is greater than $10,000.00, the script must return the result set consisting of VendorName,

  Top-down modular approach and pseudocode to create program

Use top-down modular approach and pseudocode to create a appropriate program to solve it. Where suitable, use defensive programming techniques. Give both pseudocode and flow chart algorithms.

  Write code to takes input from console

Write code using C++ which takes input from console and displays output on console. You will write program which takes user input, does some basic arithmetic, and displays the results.

  Computer sales and repair store system

It is required to design a relational database system for a "realistic" application

  Write an algorithm that converts a linear measurement

Write an algorithm that converts a linear measurement in feet and inches into meters. One inch is equivalent to 2.54 centimeters.

  Implement method to create thousand random integers

Implement a method named posNeg which creates 1000 random integers. Range of numbers must be from -5 to +5 inclusive.

  Write program to instantiate objects of inherited classes

X-Y coordinate pairs for four endpoints of Quadrilateral. Write program which instantiates objects of the classes and outputs each object's area.

  Design tower of hanoi puzzle program

Implement and design Tower of Hanoi Puzzle program using C# and Windows Presentation Foundation WPF template in Visual Studio 2012 or newer.

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