I'm working on assignment that requires me to generate and store 50 random PPS Numbers in an array but I'm not sure as to how to go about doing this. Keep in mind that I'm not asking anyone to do this assignment for me, this is just the part I need help with
Personal Public Servive Number, It's a number that's 7 characters in lenght with a letter at the end e.g 000000E
I know how to generate a random number but I don't know how to generate one with a letter at the end
If there's a letter in there then you cannot create it as a numeric type, it has to be a String. Generate the 7 digit number, convert it to String, add the letter on the end.
If that's an Irish PPS then there's a very clear description of how to generate the letter in the WikiPedia article
I looked up PPS on wiki to see how it is calculated. Once the proper number is calculated, you can simply cast it to a char to match it up with an ASCII table.
Random r = new Random();
StringBuilder sb = new StringBuilder(8);
int x = 0;
int n = r.nextInt(10);
x = n * (8-i);
// Add 64 to the modulus result and cast
// to a char to convert the number to the
// corresponding letter in the ASCII table
sb.append((char)(x % 23 + 64));
I believe this method would do the least amount of casting/conversion between numbers and strings. However, it does leave the potential for the following to be generated: 0000000@
Hi I'm having a problem implementing a mini shopping cart drop down in the header to show the user all the products they have in their shopping cart. It seems the only solution for this is Ajax, and I've looked all over and can't find anything that I could possibly ...
Help! I want to create a java program that finds the highest even integer among the values entered by the user. Stop asking values when a value less than 1 have been entered. If no even integer is entered, display "No Even Integer"