Advertisement
Vendrick-Xander

Two Programs HW

Jan 15th, 2019
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.48 KB | None | 0 0
  1. Here is the code for the first program:
  2. package com.Suarez;
  3. /*
  4. Xander Fermier
  5. 1/15/19
  6. the user inputs two passwords and if they match then it will confirm their passwrod, if not it will deny it
  7. */
  8.  
  9. import java.util.*;
  10.  
  11. public class PasswordCheck {
  12. public static void main(String[] args)
  13. {
  14. System.out.println("Enter your password.");
  15. Scanner scan = new Scanner(System.in);
  16. String pass1 = scan.next();
  17. System.out.println("Confirm your passwords");
  18. String pass2 = scan.next();
  19.  
  20. if (pass1.equals(pass2))
  21. {
  22. System.out.println("You are now registered as a new user.");
  23. }
  24. else
  25. {
  26. System.out.println("Sorry, there is a typo in your password");
  27. }
  28. }
  29. }
  30.  
  31. Here is the code for the second program:
  32. package com.Suarez;
  33. /*
  34. Xander Fermier
  35. 1/15/19
  36. the user inputs an ID and then the computer determines whether or not it is valid based on its length
  37. */
  38.  
  39.  
  40. import java.util.*;
  41.  
  42. public class UserIDTest {
  43. public static void main(String [] args)
  44. {
  45. System.out.println("Enter a username.");
  46. Scanner scan = new Scanner(System.in);
  47. String username = scan.next();
  48. int userlength = username.length();
  49. if (userlength >= 6 && userlength <= 10)
  50. {
  51. System.out.print("Welcome, " + username);
  52. }
  53. else
  54. {
  55. System.out.print("Sorry, user ID invalid");
  56. }
  57.  
  58. }
  59. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement