Uploaded by erronn madelo

Authentication and Basic Mathematical Operations

advertisement
Authentication and Basic Mathematical Operations
package authentication;
import java.util.Scanner;
public class Authentication {
public static void main(String[] args) {
String username, password;
int sum, number1, number2 = 0;
char Ans;
do {
Scanner s = new Scanner(System.in);
System.out.print("Enter username: ");
username = s.nextLine();
System.out.print("Enter password: ");
password = s.nextLine();
if (username.equals("user") && password.equals("user")){
System.out.println("Authentication successful");
System.out.println("ADDITION OPERATION");
System.out.print("Enter number 1: "); number1 = s.nextInt();
System.out.println(" ");
System.out.print("Enter number 2: "); number2 = s.nextInt();
sum = number1+number2;
System.out.println("TOTAL: "+sum);
}
else {
System.out.println("Authentication failed");
}
System.out.print("Try again? [Y/y]: ");
Ans=s.next().charAt(0);
}while ((Ans == 'Y')|| (Ans== 'y'));
}
}
Download