Advertisement
Guest User

Exercise 20: Usernames

a guest
Oct 27th, 2018
185
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.79 KB | None | 0 0
  1. import java.util.Scanner;
  2. public class Main{
  3.     public static void main(String[] args) {
  4.         Scanner reader = new Scanner(System.in);
  5.         System.out.print("Type your username: ");
  6.         String username = reader.nextLine();
  7.         System.out.print("Type your password: ");
  8.         String password = reader.nextLine();
  9.         if (username.equals("alex")) {
  10.             if(password.equals("mightyducks")){
  11.                 System.out.println("You are now logged into the system!");
  12.             }
  13.         } else if (username.equals("emily")) {
  14.             if(password.equals("cat")){
  15.                 System.out.println("You are now logged into the system!");
  16.             }
  17.         } else {
  18.             System.out.println("Your username or password was invalid!");
  19.         }
  20.     }
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement