Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class TheClass{
- static String UserNameMain = "";
- static String PasswordMain = "";
- // This is the main function everything into one
- public static void main(String arg[]){
- do{ // This do while loop loops the user input function untill the username != password
- EnteringDatea();
- }while(ReturnPass().equals(ReturnUser()));
- // This while loop, loops the Again() function when the user presses 'y' to do again
- // getting the data from the "return again"
- while (Again() == 'y' || Again() == 'Y'){
- Again();
- }
- }
- // This function is the loop where it askes if you want to do it again y/n
- public static char Again(){
- Scanner input = new Scanner(System.in);
- char again;
- System.out.println("Would you like to input info. again?");
- again = input.nextLine().charAt(0);
- if (again == 'y' || Again() == 'Y'){
- EnteringDatea();
- }
- else if (again == 'n' || again == 'N'){
- System.err.println("Program Terminated");
- }
- else {
- System.out.println("Invalid");
- }
- return again; // returns again so the main() function can see what the user chose
- // to do again yes 'y' or no 'n'
- }
- // This is where the user enters the username / password
- public static void EnteringDatea(){
- Scanner input = new Scanner(System.in);
- System.out.println("Enter your UserName");
- String Username = input.nextLine();
- UserInput(Username);
- System.out.println("Enter your Password");
- String Password = input.nextLine();
- PassInput(Password);
- Message();
- }
- // \/\/\/\/\/\/ Dont worry about that
- // UserName Input
- public static void UserInput(String UserName){
- UserNameMain = UserName;
- }
- // Password Input
- public static void PassInput(String Password){
- PasswordMain = Password;
- }
- // Return UserName
- public static String ReturnUser(){
- return UserNameMain;
- }
- // Return Password
- public static String ReturnPass(){
- return PasswordMain;
- }
- // Output Message
- public static void Message(){
- if(ReturnPass().equals(ReturnUser())){
- System.out.println("Password needs to be different from UserName\n");
- }
- else{
- System.out.println("UserName = " + ReturnUser());
- System.out.println("Password = " + ReturnPass());
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement