Write a Java program to read a password. If the password equals to 1234 then print out “Your password is accepted”. Otherwise print “Your password is Not Accepted”.
Flowchart
![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiMflXR1daQsBur074yV-lMZxthvKTlOrObzZkCR9ppLycfqksiIyZpbbxBrlewXRmkF2UXfa86KLHOWG9cir21hhTg87vUNDOvOIWwum5UlLTFGNoNPB-6A0Drd9-HBniVuMSpD3VR7Fc/s320/lab3_1.png)
Java Program
/**
* @(#)Lab3_1.java
*
* Lab3_1 application
*
* @author
* @version 1.00 2010/8/4
*/
import javax.swing.*;
public class Lab3_1 {
public static void main(String[] args) {
// TODO, add your application code
int password;
String answerString = JOptionPane.showInputDialog ("Please enter your password");
password = Integer.parseInt(answerString);
if(password == 1234)
JOptionPane.showMessageDialog(null,"Your Password is Accepted" );
else
JOptionPane.showMessageDialog(null,"Your Password is NOT Accepted" );
}
}
No comments:
Post a Comment