Advertisement
Triacontakai

AP:CSP Login System

Nov 29th, 2017
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.30 KB | None | 0 0
  1. /**
  2.  * Triacontakai
  3.  * Fun Overcomplicated Login System
  4.  */
  5. import java.util.Scanner;
  6. public class KotliarovA_Woots {
  7.     public static void main(String[] args) {
  8.         Scanner input = new Scanner(System.in);
  9.        
  10.         String[] user = {"HexBeetle75", "SparklePony10", "PetPet"};
  11.         String[] pass = {"invasivespecies", "glitterific!", "particardi"}; //could use 1 array but thats ugly
  12.        
  13.         System.out.print("Username: ");
  14.         String userin = input.nextLine();
  15.         System.out.print("Password: ");
  16.         String passin = input.nextLine();
  17.        
  18.         boolean userval = false;
  19.         boolean passval = false;
  20.         for(int i = 0; i < 3; i++) {           //oh boy here's the fun part
  21.             if(userin.equals(user[i])) {       //this probably could have been simpler
  22.                 userval = true;                //but it works!
  23.                 if(passin.equals(pass[i]))
  24.                     passval = true;
  25.             }
  26.         }
  27.         if(!userval) {
  28.             System.out.println("No account with the username \""+ userin +"\".");
  29.         }
  30.         else if(!passval) {
  31.             System.out.println("Password incorrect!");
  32.         }
  33.         else {
  34.             System.out.println("Welcome, "+ userin +"!");
  35.         }
  36.         input.close();
  37.     }
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement