Get Job-ready: Java Course with 45+ Real-time Projects! - Learn Java
Program 1
import java.io.*;
import java.util.Scanner;
class TestLogin
{
public static void main(String args[])
{
String user,pass;
char ch[];
Console c=System.console();
//System.out.println("Enter User Name: ");
user=c.readLine("Enter User Name:");
//System.out.println("Enter Password: ");
ch=c.readPassword("Enter Password: ");
pass=new String(ch);
if(user.equalsIgnoreCase("vivek") && pass.equals("indore"))
{
Scanner scan=new Scanner(System.in);
int choice;
do
{
System.out.println("-----------------Menu Application----------------------");
System.out.println(" 1.Factorial \n 2.Reverse of Number\n 3.Addition of Number\n 4.Exit");
System.out.println("----------------------------------------------------------");
choice=scan.nextInt();
switch(choice)
{
case 1:
System.out.println("This is program for factorial ");break;
case 2:
System.out.println("This is program for reverse ");break;
case 3:
System.out.println("This is program for Addtion ");break;
case 4:break;
}
}while(choice!=4);
// System.out.println("User Name: " +user);
// System.out.println("Password: " +pass);
}
else
System.out.println("Invalid user id or password");
}
}
/*
String readLine()
String readLine(String format)
String readPassword()
String readPassword(String format)
*/