Need help with simple program.
Go to solution
Solved by jimakos234,
Damn i had to mess around with java 2-3 years...
NumberFormat integerFormat = NumberFormat.getIntegerInstance(); NumberFormat integerFormat2 = NumberFormat.getIntegerInstance(); integerFormat.setMinimumIntegerDigits(3); integerFormat.setGroupingUsed(false); integerFormat2.setMinimumIntegerDigits(4); integerFormat2.setGroupingUsed(false); Random generator = new Random(); int num123, num456, num7890; do{ //if it cant contain 8 or 9 u had it set at 777, which is wrong, because 689 would be a correct input from the programm num123 = generator.nextInt(999) + 1; }while(String.valueOf(num123).contains("8")||String.valueOf(num123).contains("9")); num456 = generator.nextInt(743) + 1; num7890 = generator.nextInt(9999) + 1; System.out.println("Your new random phone number is " + integerFormat.format(num123) + "-" + integerFormat.format(num456) + "-" + integerFormat2.format(num7890));
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now