Wednesday 18 August 2021

Student Marks Calculation app using java

 

 

 

import javax.swing.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

public class Student {
private JTextField txtStname;
private JButton calButton;
private JTextField txtMarks1;
private JTextField txtMarks2;
private JTextField txtMark3;
private JTextField txtTotal;
private JTextField txtAvg;
private JTextField txtGrade;
private JPanel Main;

public static void main(String[] args) {
JFrame frame = new JFrame("Student");
frame.setContentPane(new Student().Main);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.pack();
frame.setVisible(true);
}

public Student() {
calButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {



int m1,m2,m3, tot;
double avg;


m1 =Integer.parseInt(txtMarks1.getText());
m2 =Integer.parseInt(txtMarks2.getText());
m3 =Integer.parseInt(txtMark3.getText());



tot =m1 + m2 + m3;

txtTotal.setText(String.valueOf(tot));



avg = tot/3;

txtAvg.setText(String.valueOf(avg));



if(avg>50)
{
txtGrade.setText("Pass");
}

else
{
txtGrade.setText("Fail");
}







}
});
}
}

 

Thursday 19 November 2020

Life Cycle Of An Applet

 

 *****Life Cycle   Of  An  Applet ****

 

 

Applet  Life Cycle:-    

                                  All  but  the most  trivial  applets  override a set  of methods  that  provides  the basic  mechanism by  which  the browser  or  applet  viewer  interfaces    to the  applet  and  controls  its execution .  Four  of these  methods:-  

                               1. init( )

                               2.  start( )

                               3.  stop( )

                               4.  destroy( )


apply  to all  applets and   are  defined  by Applet.  Default implementations  for all  of these  methods  are  provided. Applets do not  need  to override  those  methods they  do not  use.  However ,  only  very  simple  applets will  not  need  to  define all  of them .  AWT  based  applets  will  also  override  the paint( )  method,  which  is  defined  by the  AWT   Component  class . This  method  is called  when the applet's  output  must be  redisplayed.

 

 

                    

                           Thank you 



Java Applets

 

 

           Java Applets 



Applets  :-    

             An  applets  is a  Java program that  runs in a Web browser.  An applet can  be a  fully  functional  Java  application because  it has the entire Java API at  its disposal. There are some  important  differences between  an applet and  a standalone Java application, including the following :



1.  An  applet is a Java class  that  extends the java.applet.Applet class.


2.   A main ( ) method  is not  invoked  on an  applet ,  and  an applet class will not  define main( ).


3.  Applets are  designed  to be  embedded within  an HTML page.


4.   When  a user  view  an HTML  page  that  contains an  applet ,  the code for the  applet is downloaded  o the  user's machine.


5.  A   JVM    is required to  view an  applet .  The JVM  can be  either a plug- in  of  the Web  browser or  a separate runtime  environment.


6.  The  JVM   on the user's  machine  creates  an  instance of the  applet class and  invokes  various  methods  during  the  applet's lifetime.


7.  Applets  have  strict security rules that  are  enforced  by  the Web browser .  The  security  of  an  applet is often referred  to as  sandbox  security , comparing the  applet to  a child  playing  in a sandbox with  various rules  that  must be followed.


8.  Other  classes  that  the  applet  needs can be downloaded  in a single Java Archive (JAR) file.


9.  Applets are  the small  programs while  applications  are  larger programs.


10.  Applets  are designed  just for  handling the client site  problems , while  the Java  applications are  designed  to work  with the client as well as server.


                   Thank you



Sunday 8 November 2020

Example of this keyword in JAVA

 

 

Example of this keyword in JAVA


Program:-


class Student

{

   int id;

   String name;

   Student(int id, String name)

    {

         this.id = id;

          this.name = name;

     }

void display( )

{

    System.out.println(id +"  "+ name);

 }

public static void main(String args[])

 {

    Student s1 = new student(111, "Karan");

    Student s2 = new student(222, "Ram"); 

    s1.display( );

    s2.display( );

 

   }


 }


OUTPUT:-

111 Karan

222 Ram

 

 

 

 




















 

 Write a program to accept a number through command line argument and find factorial of the number.



Program:-


class Fact

{

    public static void main(String args[])

     {

        if(args.length !=1)

         System.out.println("Wrong arguments");

        else

         {

            int n = Integer.parselnt(args[0]);

            int f=1;

            for(int i = 1;i<=n;i++)

                 f = f*i;

            System.out.println("Factorial of "+n+" is + f);



          }


      }


 }

 

 

 

OUTPUT:-

 

C:\java\bin>java Fact 5

Factorial of 5 is 120

 


Write a program to read two number from command line argument and add them.

 

 

Write  a program to read two number from command line argument and add them.

 

 

Program:-

 

class Sum 

{

    public static void main(String ar[])

      {

         int x, y,s;

         x = integer.parselnt(ar[0]);

         y = integer.parselnt(ar[1]);

         s = x+y;

         System.out.println("sum of "+x+" and"+y+" is " +s);

 

       

       }

  }

   

 

 


Friday 6 November 2020

What are the characteristics and jealous of OOP(Object Oriented Programming?

 

 

 

 What are the characteristics and jealous of OOP(Object Oriented Programming?

 

 

Characteristics of OOPS   are:-


1.  Emphasis is on data rather than  procedure.

2.  Programs are divided into  what  are known as objects.

3.  Data  structures are  designed such that  they  characterize the objects.

4.  Functions that  operate on the  data  of an object are tied together in the data structure.

5.  Data  is hidden  and cannot  be accessed by  external functions.

6.  Objects may  communicate with  each  other through  functions.

7.   New  data and functions can be  easily added  whenever necessary.

8.  Follows  bottom up  approach in program design.





Student Marks Calculation app using java

      import javax.swing. *; import java.awt.event.ActionEvent ; import java.awt.event.ActionListener ; public class Student { private J...