ARTICLE AD BOX
I'm coding in java on Netbeans, where your project automatically gives you code to run hello world when you start a new project. I have saved my current code (which doesn't contain anything to output hello world), and it is the only code file in my project, yet when I run that file, it doesn't run my existing code and only outputs Hello world. I have tried running the code by right-clicking on the file, cleaning before I build, and creating a new project with the same code to see if it's an isolated issue (it isn't; those files don't run the code either), but nothing seems to resolve the issue. I have saved my code to a repository on github if that makes any difference, but there are no problems with my actual code that I can find. I would appreciate any advice on how to get my code to run.
Here is the code I have if it makes any difference.
package com.mycompany.login; import java.util.Scanner; public class Login { //Declare the attributes private String firstName = " "; private String lastName = " "; private String username = " "; private String loginUsername = " "; private String password = " "; private String loginPassword = " "; private String cellNumber = " "; //Constructor public Login (String firstName, String lastName, String username, String password, String cellNumber) { this.firstName = firstName; this.lastName = lastName; this.username = username; this.loginUsername = loginUsername; this.password = password; this.loginPassword = loginPassword; this.cellNumber = cellNumber; } //Method to greet user public static void greetings() { System.out.println("Welcome to the chat app login system."); } //Check the format of the username public boolean checkUserName() { return username.matches("^.{0,5}_.*$"); } public boolean checkPasswordComplexity() { return password.matches("^(?=.*[A-Z])(?=.*\\d)(?=.*[@$!%*?&]).{8,}$"); } public boolean checkCellPhoneNumber() { return cellNumber.matches("^(\\+)\\d(1,13)$"); } public String registerUser(Scanner input){ //Ask user for a username System.out.println("Enter a username (Must contain an underscore ('_') and be no longer than 5 characters): "); //Store username username = input.nextLine(); //Check if the username matches the conditions given if (checkUserName()) { System.out.println("Username successfully captured."); //Ask user for a password System.out.println("Enter a password (Must be at least 8 characters in length, and contain a captial letter, a number and a special character): "); //Store password password = input.nextLine(); //check if password matches the conditions given if (checkPasswordComplexity()) { System.out.println("Password successfully caputured."); //Ask user for a cell number System.out.println("Enter a cell number (Must start with an international country code and be followed by no more than 10 numbers): "); //Store cell number cellNumber = input.nextLine(); //Check if password matches the conditions given if (checkCellPhoneNumber()) { System.out.println("Cell phone number successfully captured."); } else { System.out.println("Cell phone number incorrectly formatted or does not contain international code."); } } else { System.out.println("Password is not correctly formatted; please ensure that the password contains at least 8 characters, a captial letter, a number and a special character."); } } else { System.out.println("Username is not correctly formatted; please ensure that your username contains an underscore and is no more than 5 characters in length."); } return "Registration complete."; } //Check that the username and password entered during login match those entered during registration public boolean loginUser() { return loginUsername.equals(username) && loginPassword.equals(password); } public String returnLoginStatus(Scanner input) { //Ask user for their username System.out.println("Enter your username: "); //Store the username loginUsername = input.nextLine(); //Ask the user for their password System.out.println("Enter your password: "); //Store the password loginPassword = input.nextLine(); //Check if username matches the conditions given if (loginUser()) { return "Welcome " + firstName + " " + lastName + " it is great to see you again."; } else { return "username or password incorrect, please try again."; } } public static void main(String[] args) { Scanner input = new Scanner(System.in); //display the welcome message greetings(); //Ask user for their first name System.out.println("Enter your first name:"); //Store the first name String firstName = input.nextLine(); //Ask user for their last name System.out.println("Enter your last name:"); //Store the last name String lastName = input.nextLine(); //Pass names into the object Login user = new Login("","","", firstName, lastName); //Registration System.out.println(user.registerUser(input)); //Login System.out.println(user.returnLoginStatus(input)); input.close(); } }