SlideShare a Scribd company logo
1 of 9
Download to read offline
Program:-
a.
// library is imported
import java.awt.*;
import java.applet.*;
import java.awt.event.*;
import javax.swing.*;
public class JPasswordA extends Applet implements ActionListener //Class Applet is //extended
using inheritance
{boolean clicked=false,code=false; // Boolean function is defined
Label passwordlabel = new Label("Password:"); // object creation
TextField passwordfield = new TextField(15); // text field is assigned to the password
Button enterbutton = new Button("Enter");
public void init() // initialization method is defined
{
add(passwordlabel);
add(passwordfield);
add(enterbutton);
enterbutton.addActionListener(this); // button and password field is set
passwordlabel.setVisible(true);
passwordfield.setVisible(true);
}
public void actionPerformed(ActionEvent e) // method
{ String pass;
clicked=true;
pass=passwordfield.getText();
if(pass.compareTo("Rosebud")==0) // conditional statement is defined
code=true;
else
code=false;
repaint();
}
public void paint(Graphics g) //paint method is defined
{
if(clicked)
{if(code)
g.drawString("Access Granted",120,150); // according to question.
else
g.drawString("Access Denied",120,150);
}
}
}
b.
// library is imported
import java.awt.*;
import java.applet.*;
import java.awt.event.*;
import javax.swing.*;
public class JPasswordB extends Applet implements ActionListener//Class Applet is //extended
using inheritance
{boolean clicked=false,code=false; // Boolean function is defined
Label passwordlabel = new Label("Password:"); // object creation
TextField passwordfield = new TextField(15); // text field is assigned to the password
Button enterbutton = new Button("Enter");
public void init()// initialization method is defined
{
add(passwordlabel);
add(passwordfield);
add(enterbutton);
enterbutton.addActionListener(this);
passwordlabel.setVisible(true); // button and password field is set
passwordfield.setVisible(true);
}
public void actionPerformed(ActionEvent e) // method
{ String pass;
clicked=true;
pass=passwordfield.getText();
if(pass.compareToIgnoreCase("Rosebud")==0) // conditional statement is defined
code=true;
else
code=false;
repaint();
}
public void paint(Graphics g) //paint method is defined
{
if(clicked)
{if(code)
g.drawString("Access Granted",120,150); // according to question.
else
g.drawString("Access Denied",120,150);
}
}
}
c.
// library is imported
import java.awt.*;
import java.applet.*;
import java.awt.event.*;
import javax.swing.*;
public class JPasswordC extends Applet implements ActionListener //Class Applet is //extended
using inheritance
{boolean clicked=false,code=false;
Label passwordlabel = new Label("Password:"); // Boolean function is defined
TextField passwordfield = new TextField(15);
Button enterbutton = new Button("Enter"); // object creation
public void init()// text field is assigned to the password
{
add(passwordlabel);
add(passwordfield);
add(enterbutton);
enterbutton.addActionListener(this); // button and password field is set
passwordlabel.setVisible(true);
passwordfield.setVisible(true);
}
public void actionPerformed(ActionEvent e) // method
{ String pass;
String pw[]={"Rosebud", "Redrum", "Jason", "Surrender","Dorothy"};
clicked=true;
pass=passwordfield.getText();
code=false;
for(int i=0;i<5;i++)
if(pass.compareToIgnoreCase(pw[i])==0) // conditional statement is defined
code=true;
repaint();
}
public void paint(Graphics g) //paint method is defined
{
if(clicked)
{if(code)
g.drawString("Access Granted",120,150); // according to question.
else
g.drawString("Access Denied",120,150);
}
}
}
Solution
Program:-
a.
// library is imported
import java.awt.*;
import java.applet.*;
import java.awt.event.*;
import javax.swing.*;
public class JPasswordA extends Applet implements ActionListener //Class Applet is //extended
using inheritance
{boolean clicked=false,code=false; // Boolean function is defined
Label passwordlabel = new Label("Password:"); // object creation
TextField passwordfield = new TextField(15); // text field is assigned to the password
Button enterbutton = new Button("Enter");
public void init() // initialization method is defined
{
add(passwordlabel);
add(passwordfield);
add(enterbutton);
enterbutton.addActionListener(this); // button and password field is set
passwordlabel.setVisible(true);
passwordfield.setVisible(true);
}
public void actionPerformed(ActionEvent e) // method
{ String pass;
clicked=true;
pass=passwordfield.getText();
if(pass.compareTo("Rosebud")==0) // conditional statement is defined
code=true;
else
code=false;
repaint();
}
public void paint(Graphics g) //paint method is defined
{
if(clicked)
{if(code)
g.drawString("Access Granted",120,150); // according to question.
else
g.drawString("Access Denied",120,150);
}
}
}
b.
// library is imported
import java.awt.*;
import java.applet.*;
import java.awt.event.*;
import javax.swing.*;
public class JPasswordB extends Applet implements ActionListener//Class Applet is //extended
using inheritance
{boolean clicked=false,code=false; // Boolean function is defined
Label passwordlabel = new Label("Password:"); // object creation
TextField passwordfield = new TextField(15); // text field is assigned to the password
Button enterbutton = new Button("Enter");
public void init()// initialization method is defined
{
add(passwordlabel);
add(passwordfield);
add(enterbutton);
enterbutton.addActionListener(this);
passwordlabel.setVisible(true); // button and password field is set
passwordfield.setVisible(true);
}
public void actionPerformed(ActionEvent e) // method
{ String pass;
clicked=true;
pass=passwordfield.getText();
if(pass.compareToIgnoreCase("Rosebud")==0) // conditional statement is defined
code=true;
else
code=false;
repaint();
}
public void paint(Graphics g) //paint method is defined
{
if(clicked)
{if(code)
g.drawString("Access Granted",120,150); // according to question.
else
g.drawString("Access Denied",120,150);
}
}
}
c.
// library is imported
import java.awt.*;
import java.applet.*;
import java.awt.event.*;
import javax.swing.*;
public class JPasswordC extends Applet implements ActionListener //Class Applet is //extended
using inheritance
{boolean clicked=false,code=false;
Label passwordlabel = new Label("Password:"); // Boolean function is defined
TextField passwordfield = new TextField(15);
Button enterbutton = new Button("Enter"); // object creation
public void init()// text field is assigned to the password
{
add(passwordlabel);
add(passwordfield);
add(enterbutton);
enterbutton.addActionListener(this); // button and password field is set
passwordlabel.setVisible(true);
passwordfield.setVisible(true);
}
public void actionPerformed(ActionEvent e) // method
{ String pass;
String pw[]={"Rosebud", "Redrum", "Jason", "Surrender","Dorothy"};
clicked=true;
pass=passwordfield.getText();
code=false;
for(int i=0;i<5;i++)
if(pass.compareToIgnoreCase(pw[i])==0) // conditional statement is defined
code=true;
repaint();
}
public void paint(Graphics g) //paint method is defined
{
if(clicked)
{if(code)
g.drawString("Access Granted",120,150); // according to question.
else
g.drawString("Access Denied",120,150);
}
}
}

More Related Content

Similar to Program-a. library is importedimport java.awt.; import j.pdf

Ejemplos Interfaces Usuario 3
Ejemplos Interfaces Usuario 3Ejemplos Interfaces Usuario 3
Ejemplos Interfaces Usuario 3
martha leon
 
10 awt event model
10 awt event model10 awt event model
10 awt event model
Bayarkhuu
 
How do I make my JTable non editableimport java.awt.; import j.pdf
How do I make my JTable non editableimport java.awt.; import j.pdfHow do I make my JTable non editableimport java.awt.; import j.pdf
How do I make my JTable non editableimport java.awt.; import j.pdf
forwardcom41
 
Convert the following program so that it uses JList instead of JComb.pdf
Convert the following program so that it uses JList instead of JComb.pdfConvert the following program so that it uses JList instead of JComb.pdf
Convert the following program so that it uses JList instead of JComb.pdf
bermanbeancolungak45
 
Please help!!I wanted to know how to add a high score to this prog.pdf
Please help!!I wanted to know how to add a high score to this prog.pdfPlease help!!I wanted to know how to add a high score to this prog.pdf
Please help!!I wanted to know how to add a high score to this prog.pdf
JUSTSTYLISH3B2MOHALI
 
Java!!!!!Create a program that authenticates username and password.pdf
Java!!!!!Create a program that authenticates username and password.pdfJava!!!!!Create a program that authenticates username and password.pdf
Java!!!!!Create a program that authenticates username and password.pdf
arvindarora20042013
 
database propertiesjdbc.url=jdbcderbyBigJavaDB;create=true # .pdf
database propertiesjdbc.url=jdbcderbyBigJavaDB;create=true # .pdfdatabase propertiesjdbc.url=jdbcderbyBigJavaDB;create=true # .pdf
database propertiesjdbc.url=jdbcderbyBigJavaDB;create=true # .pdf
fashiionbeutycare
 
Othello.javapackage othello;import core.Game; import userInter.pdf
Othello.javapackage othello;import core.Game; import userInter.pdfOthello.javapackage othello;import core.Game; import userInter.pdf
Othello.javapackage othello;import core.Game; import userInter.pdf
arccreation001
 
import java.awt.FlowLayout;import java.awt.event.KeyEvent;import.pdf
import java.awt.FlowLayout;import java.awt.event.KeyEvent;import.pdfimport java.awt.FlowLayout;import java.awt.event.KeyEvent;import.pdf
import java.awt.FlowLayout;import java.awt.event.KeyEvent;import.pdf
galagirishp
 

Similar to Program-a. library is importedimport java.awt.; import j.pdf (20)

Ejemplos Interfaces Usuario 3
Ejemplos Interfaces Usuario 3Ejemplos Interfaces Usuario 3
Ejemplos Interfaces Usuario 3
 
10 awt event model
10 awt event model10 awt event model
10 awt event model
 
Maze
MazeMaze
Maze
 
Tuto jtatoo
Tuto jtatooTuto jtatoo
Tuto jtatoo
 
How do I make my JTable non editableimport java.awt.; import j.pdf
How do I make my JTable non editableimport java.awt.; import j.pdfHow do I make my JTable non editableimport java.awt.; import j.pdf
How do I make my JTable non editableimport java.awt.; import j.pdf
 
Creating a Facebook Clone - Part XLVI.pdf
Creating a Facebook Clone - Part XLVI.pdfCreating a Facebook Clone - Part XLVI.pdf
Creating a Facebook Clone - Part XLVI.pdf
 
Convert the following program so that it uses JList instead of JComb.pdf
Convert the following program so that it uses JList instead of JComb.pdfConvert the following program so that it uses JList instead of JComb.pdf
Convert the following program so that it uses JList instead of JComb.pdf
 
New text document
New text documentNew text document
New text document
 
Please help!!I wanted to know how to add a high score to this prog.pdf
Please help!!I wanted to know how to add a high score to this prog.pdfPlease help!!I wanted to know how to add a high score to this prog.pdf
Please help!!I wanted to know how to add a high score to this prog.pdf
 
Java!!!!!Create a program that authenticates username and password.pdf
Java!!!!!Create a program that authenticates username and password.pdfJava!!!!!Create a program that authenticates username and password.pdf
Java!!!!!Create a program that authenticates username and password.pdf
 
database propertiesjdbc.url=jdbcderbyBigJavaDB;create=true # .pdf
database propertiesjdbc.url=jdbcderbyBigJavaDB;create=true # .pdfdatabase propertiesjdbc.url=jdbcderbyBigJavaDB;create=true # .pdf
database propertiesjdbc.url=jdbcderbyBigJavaDB;create=true # .pdf
 
Creating a Facebook Clone - Part XLVI - Transcript.pdf
Creating a Facebook Clone - Part XLVI - Transcript.pdfCreating a Facebook Clone - Part XLVI - Transcript.pdf
Creating a Facebook Clone - Part XLVI - Transcript.pdf
 
Othello.javapackage othello;import core.Game; import userInter.pdf
Othello.javapackage othello;import core.Game; import userInter.pdfOthello.javapackage othello;import core.Game; import userInter.pdf
Othello.javapackage othello;import core.Game; import userInter.pdf
 
Google guava
Google guavaGoogle guava
Google guava
 
import java.awt.FlowLayout;import java.awt.event.KeyEvent;import.pdf
import java.awt.FlowLayout;import java.awt.event.KeyEvent;import.pdfimport java.awt.FlowLayout;import java.awt.event.KeyEvent;import.pdf
import java.awt.FlowLayout;import java.awt.event.KeyEvent;import.pdf
 
Java: GUI
Java: GUIJava: GUI
Java: GUI
 
Groovy-er desktop applications with Griffon
Groovy-er desktop applications with GriffonGroovy-er desktop applications with Griffon
Groovy-er desktop applications with Griffon
 
Groovy-er Desktop Applications With Griffon
Groovy-er Desktop Applications With GriffonGroovy-er Desktop Applications With Griffon
Groovy-er Desktop Applications With Griffon
 
CORE JAVA-2
CORE JAVA-2CORE JAVA-2
CORE JAVA-2
 
Applet
AppletApplet
Applet
 

More from aparnacollection

What is an OS • Interface between application programs and hardwa.pdf
What is an OS • Interface between application programs and hardwa.pdfWhat is an OS • Interface between application programs and hardwa.pdf
What is an OS • Interface between application programs and hardwa.pdf
aparnacollection
 
The multiplication sign simply means that the molecules have their i.pdf
The multiplication sign simply means that the molecules have their i.pdfThe multiplication sign simply means that the molecules have their i.pdf
The multiplication sign simply means that the molecules have their i.pdf
aparnacollection
 
package com.test;public class Team {    private String teamId;.pdf
package com.test;public class Team {    private String teamId;.pdfpackage com.test;public class Team {    private String teamId;.pdf
package com.test;public class Team {    private String teamId;.pdf
aparnacollection
 
Given below is the completed code along with comments. Output of the.pdf
Given below is the completed code along with comments. Output of the.pdfGiven below is the completed code along with comments. Output of the.pdf
Given below is the completed code along with comments. Output of the.pdf
aparnacollection
 
(a) The American Institute of Certified Accountants. (AICPA)(b) Th.pdf
(a) The American Institute of Certified Accountants. (AICPA)(b) Th.pdf(a) The American Institute of Certified Accountants. (AICPA)(b) Th.pdf
(a) The American Institute of Certified Accountants. (AICPA)(b) Th.pdf
aparnacollection
 
Yes. The compound is actively active. It is mainl.pdf
                     Yes. The compound is actively active. It is mainl.pdf                     Yes. The compound is actively active. It is mainl.pdf
Yes. The compound is actively active. It is mainl.pdf
aparnacollection
 
Adding elements public void add(String element) { For fi.pdf
 Adding elements public void add(String element) {  For fi.pdf Adding elements public void add(String element) {  For fi.pdf
Adding elements public void add(String element) { For fi.pdf
aparnacollection
 
1) Investment Grade Domestic Bonds As bond bears a fixed rate of i.pdf
    1) Investment Grade Domestic Bonds As bond bears a fixed rate of i.pdf    1) Investment Grade Domestic Bonds As bond bears a fixed rate of i.pdf
1) Investment Grade Domestic Bonds As bond bears a fixed rate of i.pdf
aparnacollection
 

More from aparnacollection (20)

}Solution}.pdf
}Solution}.pdf}Solution}.pdf
}Solution}.pdf
 
What is an OS • Interface between application programs and hardwa.pdf
What is an OS • Interface between application programs and hardwa.pdfWhat is an OS • Interface between application programs and hardwa.pdf
What is an OS • Interface between application programs and hardwa.pdf
 
Using a broad definition of file(note that it doesnt count h.pdf
Using a broad definition of file(note that it doesnt count h.pdfUsing a broad definition of file(note that it doesnt count h.pdf
Using a broad definition of file(note that it doesnt count h.pdf
 
unable to open it ....it asks for username and passwordSolution.pdf
unable to open it ....it asks for username and passwordSolution.pdfunable to open it ....it asks for username and passwordSolution.pdf
unable to open it ....it asks for username and passwordSolution.pdf
 
This is called a dehydrationreaction. a) H2SO4 H20Solution.pdf
This is called a dehydrationreaction. a) H2SO4  H20Solution.pdfThis is called a dehydrationreaction. a) H2SO4  H20Solution.pdf
This is called a dehydrationreaction. a) H2SO4 H20Solution.pdf
 
The multiplication sign simply means that the molecules have their i.pdf
The multiplication sign simply means that the molecules have their i.pdfThe multiplication sign simply means that the molecules have their i.pdf
The multiplication sign simply means that the molecules have their i.pdf
 
SolutionThe variance of individual assets is measure of total ris.pdf
SolutionThe variance of individual assets is measure of total ris.pdfSolutionThe variance of individual assets is measure of total ris.pdf
SolutionThe variance of individual assets is measure of total ris.pdf
 
soldefnition of critical thinkingit is an intellectual process o.pdf
soldefnition of critical thinkingit is an intellectual process o.pdfsoldefnition of critical thinkingit is an intellectual process o.pdf
soldefnition of critical thinkingit is an intellectual process o.pdf
 
package com.test;public class Team {    private String teamId;.pdf
package com.test;public class Team {    private String teamId;.pdfpackage com.test;public class Team {    private String teamId;.pdf
package com.test;public class Team {    private String teamId;.pdf
 
Given below is the completed code along with comments. Output of the.pdf
Given below is the completed code along with comments. Output of the.pdfGiven below is the completed code along with comments. Output of the.pdf
Given below is the completed code along with comments. Output of the.pdf
 
(a) The American Institute of Certified Accountants. (AICPA)(b) Th.pdf
(a) The American Institute of Certified Accountants. (AICPA)(b) Th.pdf(a) The American Institute of Certified Accountants. (AICPA)(b) Th.pdf
(a) The American Institute of Certified Accountants. (AICPA)(b) Th.pdf
 
Yes. The compound is actively active. It is mainl.pdf
                     Yes. The compound is actively active. It is mainl.pdf                     Yes. The compound is actively active. It is mainl.pdf
Yes. The compound is actively active. It is mainl.pdf
 
The probability of A and its complement will sum to oneSolution.pdf
 The probability of A and its complement will sum to oneSolution.pdf The probability of A and its complement will sum to oneSolution.pdf
The probability of A and its complement will sum to oneSolution.pdf
 
H+,CN-Solution H+,CN-.pdf
 H+,CN-Solution H+,CN-.pdf H+,CN-Solution H+,CN-.pdf
H+,CN-Solution H+,CN-.pdf
 
Adding elements public void add(String element) { For fi.pdf
 Adding elements public void add(String element) {  For fi.pdf Adding elements public void add(String element) {  For fi.pdf
Adding elements public void add(String element) { For fi.pdf
 
1) Investment Grade Domestic Bonds As bond bears a fixed rate of i.pdf
    1) Investment Grade Domestic Bonds As bond bears a fixed rate of i.pdf    1) Investment Grade Domestic Bonds As bond bears a fixed rate of i.pdf
1) Investment Grade Domestic Bonds As bond bears a fixed rate of i.pdf
 
When atoms share one or more pairs of electrons t.pdf
                     When atoms share one or more pairs of electrons t.pdf                     When atoms share one or more pairs of electrons t.pdf
When atoms share one or more pairs of electrons t.pdf
 
This is quite simple to do. Barium sulfate is ins.pdf
                     This is quite simple to do. Barium sulfate is ins.pdf                     This is quite simple to do. Barium sulfate is ins.pdf
This is quite simple to do. Barium sulfate is ins.pdf
 
Step1 Cocentration of NaCl =.250 moles Step2 Mol.pdf
                     Step1 Cocentration of NaCl =.250 moles  Step2 Mol.pdf                     Step1 Cocentration of NaCl =.250 moles  Step2 Mol.pdf
Step1 Cocentration of NaCl =.250 moles Step2 Mol.pdf
 
Nitric acid is a strong acid... we can assume com.pdf
                     Nitric acid is a strong acid... we can assume com.pdf                     Nitric acid is a strong acid... we can assume com.pdf
Nitric acid is a strong acid... we can assume com.pdf
 

Recently uploaded

The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
heathfieldcps1
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
kauryashika82
 
An Overview of Mutual Funds Bcom Project.pdf
An Overview of Mutual Funds Bcom Project.pdfAn Overview of Mutual Funds Bcom Project.pdf
An Overview of Mutual Funds Bcom Project.pdf
SanaAli374401
 
Gardella_PRCampaignConclusion Pitch Letter
Gardella_PRCampaignConclusion Pitch LetterGardella_PRCampaignConclusion Pitch Letter
Gardella_PRCampaignConclusion Pitch Letter
MateoGardella
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
QucHHunhnh
 

Recently uploaded (20)

Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
 
An Overview of Mutual Funds Bcom Project.pdf
An Overview of Mutual Funds Bcom Project.pdfAn Overview of Mutual Funds Bcom Project.pdf
An Overview of Mutual Funds Bcom Project.pdf
 
Gardella_PRCampaignConclusion Pitch Letter
Gardella_PRCampaignConclusion Pitch LetterGardella_PRCampaignConclusion Pitch Letter
Gardella_PRCampaignConclusion Pitch Letter
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.ppt
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
PROCESS RECORDING FORMAT.docx
PROCESS      RECORDING        FORMAT.docxPROCESS      RECORDING        FORMAT.docx
PROCESS RECORDING FORMAT.docx
 
psychiatric nursing HISTORY COLLECTION .docx
psychiatric  nursing HISTORY  COLLECTION  .docxpsychiatric  nursing HISTORY  COLLECTION  .docx
psychiatric nursing HISTORY COLLECTION .docx
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdf
 
Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1
 
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptx
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 
SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...
SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...
SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...
 
Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024
 

Program-a. library is importedimport java.awt.; import j.pdf

  • 1. Program:- a. // library is imported import java.awt.*; import java.applet.*; import java.awt.event.*; import javax.swing.*; public class JPasswordA extends Applet implements ActionListener //Class Applet is //extended using inheritance {boolean clicked=false,code=false; // Boolean function is defined Label passwordlabel = new Label("Password:"); // object creation TextField passwordfield = new TextField(15); // text field is assigned to the password Button enterbutton = new Button("Enter"); public void init() // initialization method is defined { add(passwordlabel); add(passwordfield); add(enterbutton); enterbutton.addActionListener(this); // button and password field is set passwordlabel.setVisible(true); passwordfield.setVisible(true); } public void actionPerformed(ActionEvent e) // method { String pass; clicked=true; pass=passwordfield.getText(); if(pass.compareTo("Rosebud")==0) // conditional statement is defined code=true; else code=false;
  • 2. repaint(); } public void paint(Graphics g) //paint method is defined { if(clicked) {if(code) g.drawString("Access Granted",120,150); // according to question. else g.drawString("Access Denied",120,150); } } } b. // library is imported import java.awt.*; import java.applet.*; import java.awt.event.*; import javax.swing.*; public class JPasswordB extends Applet implements ActionListener//Class Applet is //extended using inheritance {boolean clicked=false,code=false; // Boolean function is defined Label passwordlabel = new Label("Password:"); // object creation TextField passwordfield = new TextField(15); // text field is assigned to the password Button enterbutton = new Button("Enter"); public void init()// initialization method is defined { add(passwordlabel); add(passwordfield); add(enterbutton); enterbutton.addActionListener(this);
  • 3. passwordlabel.setVisible(true); // button and password field is set passwordfield.setVisible(true); } public void actionPerformed(ActionEvent e) // method { String pass; clicked=true; pass=passwordfield.getText(); if(pass.compareToIgnoreCase("Rosebud")==0) // conditional statement is defined code=true; else code=false; repaint(); } public void paint(Graphics g) //paint method is defined { if(clicked) {if(code) g.drawString("Access Granted",120,150); // according to question. else g.drawString("Access Denied",120,150); } } } c. // library is imported import java.awt.*; import java.applet.*; import java.awt.event.*; import javax.swing.*; public class JPasswordC extends Applet implements ActionListener //Class Applet is //extended using inheritance {boolean clicked=false,code=false;
  • 4. Label passwordlabel = new Label("Password:"); // Boolean function is defined TextField passwordfield = new TextField(15); Button enterbutton = new Button("Enter"); // object creation public void init()// text field is assigned to the password { add(passwordlabel); add(passwordfield); add(enterbutton); enterbutton.addActionListener(this); // button and password field is set passwordlabel.setVisible(true); passwordfield.setVisible(true); } public void actionPerformed(ActionEvent e) // method { String pass; String pw[]={"Rosebud", "Redrum", "Jason", "Surrender","Dorothy"}; clicked=true; pass=passwordfield.getText(); code=false; for(int i=0;i<5;i++) if(pass.compareToIgnoreCase(pw[i])==0) // conditional statement is defined code=true; repaint(); } public void paint(Graphics g) //paint method is defined { if(clicked)
  • 5. {if(code) g.drawString("Access Granted",120,150); // according to question. else g.drawString("Access Denied",120,150); } } } Solution Program:- a. // library is imported import java.awt.*; import java.applet.*; import java.awt.event.*; import javax.swing.*; public class JPasswordA extends Applet implements ActionListener //Class Applet is //extended using inheritance {boolean clicked=false,code=false; // Boolean function is defined Label passwordlabel = new Label("Password:"); // object creation TextField passwordfield = new TextField(15); // text field is assigned to the password Button enterbutton = new Button("Enter"); public void init() // initialization method is defined { add(passwordlabel); add(passwordfield); add(enterbutton);
  • 6. enterbutton.addActionListener(this); // button and password field is set passwordlabel.setVisible(true); passwordfield.setVisible(true); } public void actionPerformed(ActionEvent e) // method { String pass; clicked=true; pass=passwordfield.getText(); if(pass.compareTo("Rosebud")==0) // conditional statement is defined code=true; else code=false; repaint(); } public void paint(Graphics g) //paint method is defined { if(clicked) {if(code) g.drawString("Access Granted",120,150); // according to question. else g.drawString("Access Denied",120,150); } } } b. // library is imported import java.awt.*; import java.applet.*; import java.awt.event.*; import javax.swing.*; public class JPasswordB extends Applet implements ActionListener//Class Applet is //extended using inheritance {boolean clicked=false,code=false; // Boolean function is defined
  • 7. Label passwordlabel = new Label("Password:"); // object creation TextField passwordfield = new TextField(15); // text field is assigned to the password Button enterbutton = new Button("Enter"); public void init()// initialization method is defined { add(passwordlabel); add(passwordfield); add(enterbutton); enterbutton.addActionListener(this); passwordlabel.setVisible(true); // button and password field is set passwordfield.setVisible(true); } public void actionPerformed(ActionEvent e) // method { String pass; clicked=true; pass=passwordfield.getText(); if(pass.compareToIgnoreCase("Rosebud")==0) // conditional statement is defined code=true; else code=false; repaint(); } public void paint(Graphics g) //paint method is defined { if(clicked) {if(code) g.drawString("Access Granted",120,150); // according to question. else g.drawString("Access Denied",120,150); } }
  • 8. } c. // library is imported import java.awt.*; import java.applet.*; import java.awt.event.*; import javax.swing.*; public class JPasswordC extends Applet implements ActionListener //Class Applet is //extended using inheritance {boolean clicked=false,code=false; Label passwordlabel = new Label("Password:"); // Boolean function is defined TextField passwordfield = new TextField(15); Button enterbutton = new Button("Enter"); // object creation public void init()// text field is assigned to the password { add(passwordlabel); add(passwordfield); add(enterbutton); enterbutton.addActionListener(this); // button and password field is set passwordlabel.setVisible(true); passwordfield.setVisible(true); } public void actionPerformed(ActionEvent e) // method { String pass; String pw[]={"Rosebud", "Redrum", "Jason", "Surrender","Dorothy"}; clicked=true;
  • 9. pass=passwordfield.getText(); code=false; for(int i=0;i<5;i++) if(pass.compareToIgnoreCase(pw[i])==0) // conditional statement is defined code=true; repaint(); } public void paint(Graphics g) //paint method is defined { if(clicked) {if(code) g.drawString("Access Granted",120,150); // according to question. else g.drawString("Access Denied",120,150); } } }