Skip to main content

Develop an applet for drawing a human face.


Code:
import java.awt.*;
importjava.applet.*;
/* <applet code = "face" width = 300 height = 300></applet> */
public class face extends Applet
{
    public void paint(Graphics g)
    {
g.drawOval(40, 40, 120, 150);
g.drawOval(57, 75, 30, 20);
g.drawOval(110, 75, 30, 20);
g.fillOval(68, 81, 10, 10);
g.fillOval(121, 81, 10, 10);
g.drawOval(85, 100, 30, 30);
g.fillArc(60, 125, 80, 40, 180, 180);
g.drawOval(25, 92, 15, 30);
g.drawOval(160, 92, 15, 30);
    }
}
Output:


Comments

Popular posts from this blog

Develop a program using control loops in applets.

Code: import java.awt.*; import java.applet.*; public class Control extends Applet {      public void paint(Graphics g)      {      for(int i=1;i<=4;i++)     {          if(i%2==0)         {            g.fillOval(90,i*50+10,50,50);           g.setColor(Color.black);        }        else       {          g.fillOval(90,i*50+10,50,50);          g.setColor(Color.red);       }    }   } } /* <applet code=Control width=300 height=300> </applet> */ Output:

Define an exception called ‘NotMatchexception’ that is thrown when a string is not equal to ‘India’. Write a java program that uses this exception.

Code: import java.util.Scanner; class NotMatchException extends Exception {   public NotMatchException (String str)   {     System.out.println(str);   } } public class StringExc {    public static void main(String[] args)    {      Scanner scan = new Scanner(System.in);      System.out.print("Enter the string : ");      String input = scan.nextLine();      try      {        if(input.equalsIgnoreCase("India"))          System.out.println("String matched !!!");        else          throw new NotMatchException ("String not matched !!!");     }     catch (NotMatchException s)     {     ...

Develop a program to accept a Password from the user and throw “Authentication Failure” exception if the password is incorrect

import java.util.*; class Test {   public static void main(String args[])   {     try     {       System.out.println("Enter Password: ");       Scanner obj=new Scanner(System.in);       String pass= obj.nextLine();       if(!pass.equals("1234"))          System.out.println("Authentication Failure");       else          System.out.println("Welcome....!!");      }      catch (Exception e)      {        System.out.println("");      }      finally      {        System.out.println("Thank You.........!!!!!");    ...