Advertisement
Guest User

Untitled

a guest
Aug 11th, 2017
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.28 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class TheClass{
  4.  
  5. static String UserNameMain = "";
  6. static String PasswordMain = "";
  7.  
  8. // This is the main function everything into one
  9. public static void main(String arg[]){
  10.  
  11. do{ // This do while loop loops the user input function untill the username != password
  12. EnteringDatea();
  13. }while(ReturnPass().equals(ReturnUser()));
  14.  
  15. // This while loop, loops the Again() function when the user presses 'y' to do again
  16. // getting the data from the "return again"
  17. while (Again() == 'y' || Again() == 'Y'){
  18. Again();
  19. }
  20. }
  21.  
  22. // This function is the loop where it askes if you want to do it again y/n
  23. public static char Again(){
  24. Scanner input = new Scanner(System.in);
  25. char again;
  26. System.out.println("Would you like to input info. again?");
  27. again = input.nextLine().charAt(0);
  28. if (again == 'y' || Again() == 'Y'){
  29. EnteringDatea();
  30. }
  31. else if (again == 'n' || again == 'N'){
  32. System.err.println("Program Terminated");
  33. }
  34. else {
  35. System.out.println("Invalid");
  36. }
  37. return again; // returns again so the main() function can see what the user chose
  38. // to do again yes 'y' or no 'n'
  39. }
  40.  
  41. // This is where the user enters the username / password
  42. public static void EnteringDatea(){
  43. Scanner input = new Scanner(System.in);
  44.  
  45. System.out.println("Enter your UserName");
  46. String Username = input.nextLine();
  47. UserInput(Username);
  48.  
  49. System.out.println("Enter your Password");
  50. String Password = input.nextLine();
  51. PassInput(Password);
  52.  
  53. Message();
  54.  
  55. }
  56. // \/\/\/\/\/\/ Dont worry about that
  57.  
  58. // UserName Input
  59. public static void UserInput(String UserName){
  60. UserNameMain = UserName;
  61. }
  62.  
  63. // Password Input
  64. public static void PassInput(String Password){
  65. PasswordMain = Password;
  66. }
  67.  
  68. // Return UserName
  69. public static String ReturnUser(){
  70. return UserNameMain;
  71. }
  72.  
  73. // Return Password
  74. public static String ReturnPass(){
  75. return PasswordMain;
  76. }
  77.  
  78.  
  79. // Output Message
  80. public static void Message(){
  81.  
  82. if(ReturnPass().equals(ReturnUser())){
  83. System.out.println("Password needs to be different from UserName\n");
  84. }
  85. else{
  86. System.out.println("UserName = " + ReturnUser());
  87. System.out.println("Password = " + ReturnPass());
  88. }
  89.  
  90. }
  91. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement