HarrJ

B8 Day8 nested if

Sep 19th, 2022
169
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.84 KB | None | 0 0
  1. package mattroseb8wk2;
  2. import java.util.Scanner;
  3.  
  4. // what if 8A is modified to also accept usernames in nested if form
  5. // with conditions from file 7E
  6. public class Day08B {
  7. public static void main(String[] args) {
  8. Scanner sc = new Scanner(System.in);
  9. String username;
  10. String passWord;
  11. String correctUname = "admin";
  12. String correctPass = "123450";
  13.  
  14. System.out.print("Enter username : ");
  15. username = sc.nextLine();
  16.  
  17. System.out.print("Enter password : ");
  18. passWord = sc.nextLine();
  19.  
  20. if (username.equals(correctUname)) { // cond 1
  21. if (true) { // cond 2
  22. System.out.println("Authentication complete");
  23. }
  24. } else {
  25. System.out.println("Please try again");
  26. }
  27. }
  28. }
  29.  
Advertisement
Add Comment
Please, Sign In to add comment