'How do I separate a "println" output from the "BUILD SUCCESSFULL" response from NetBeans?
I'm drawing a blank on this one, and I know it has to be a relatively easy fix.
I wrote a program for my java course that generates a random password of ASCII characters 33 - 126 at a user specified length.
Here's an example: Please enter password length: (input) 5 (output would be something like...) nNd0r .
The program works fine and everything runs smoothly, except for one tiny detail: When the output is printed, the "BUILD SUCCESSFUL" indicator from NetBeans is directly connected to that output.
My real question is: How exactly can I make the "BUILD SUCCESSFUL" indicator to be printed below my output.
Here is my code:
public static void main(String[] args) {
//Create a Scanner to provide user input.
Scanner input = new Scanner(System.in);
//Prompt the user for their input.
System.out.print("Please enter password length: ");
int answer = input.nextInt();
//Invoke the "randomPassword" method through a loop that was created below.
System.out.print("Password: ");
for (int i = 0; i < answer; i++) {
System.out.print(randomPassword(answer));
}
}
public static char randomPassword(int n) {
//Create a random number generator.
int randomNumber = 33 + (int)(Math.random() * ((126 - 33) + 1));
//Convert random number to random ASCII character between 33 - 126.
char randomChar = (char)randomNumber;
return randomChar;
}
}
Solution 1:[1]
You can add another System.out.println(""); to the last line of your code.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Danon |
