Thursday, July 30, 2009

How can I provide a limit to the number of numbers entered in a bank account number in a C++ program?

I tryd makin ma program bt I'm not able to provide a limit to the number of numerals in d bank account number.My book has prescribed me to use arrays.please advice.

How can I provide a limit to the number of numbers entered in a bank account number in a C++ program?
You can check for a range after each time the customer enters their ID:





Example:


while(accountNum %26gt; 100000000 | accountNum %26lt; 0)


%26lt;reask for input%26gt;





If you mean everything with xxx-xxx-xxx is valid then you want to make sure there are 9 digits:





int digits;


cin %26gt;%26gt; someInput;


digits = someInput/log(someInput); // this will give you the digit


// figure. 100 log 10 is 2, meaning 2 digits+1.


digits +=1;





if(digits %26gt; 9 | digits %26lt; 9) // if it has more or less than 9 then it is


// incorrect


%26lt;insert reprompt code%26gt;
Reply:just make the array as big as the length of the account number and only cin the amount needed to fill the array.

flowers online

No comments:

Post a Comment