Skip to main content

FEATURED POST

Why the World is Running Out of Computers

Question: Develop an applet that receives an integer in one text field,and computes its factorial value and return it in another text field, when the button named “Compute” is clicked

Question: Develop an applet that receives an integer in one text field,and computes its factorial value and return it in another text field, when the button named “Compute” is clicked



import java.awt.*;

import java.awt.event.*;

import java.applet.*;

public class Factorial extends Applet implements ActionListener

{

    Label l1,l2;

TextField t1,t2;

    Button com;
   
    public void init()

    {

        l1=new Label("Enter a no.");

        add(l1);

        l2=new Label("Factorial");

        add(l2);

        t1=new TextField(10);

        add(t1);

        t2=new TextField(10);

        add(t2);

        com=new Button("Compute");

        add(com);

com.addActionListener(this);



    }

    public void actionPerformed(ActionEvent e)

    {

        if(e.getSource()==com)

        {

            int i,fact=1;

              int n=Integer.parseInt(t1.getText());

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

            {

                        fact=fact*i;

            }

       t2.setText(String.valueOf(fact));

        }

    }
}


/*<applet code=Factorial.class WIDTH=300 HEIGHT=200>
</applet>  */
 OUTPUT:
















Keyword:
How to recover the classnotfoundexception in Java?
What are the top most requirements or expectations of client for develop Java web application?
Java program question paper in 2020
java applet
applet programming in java
creating applet in java










Comments

Popular Posts

Question: Create a base class called “Vehicle” that stores number of wheels and speed. Create the following derived classes

Question: Create a base class called “Vehicle” that stores number of wheels and speed. Create the following derived classes:  Ø “Car” that inherits “Vehicle” and also stores number of passengers.  Ø “Truck” that inherits “Vehicle” and also stores the load limit.  Write a main() function to create objects of these classes and display all the information about Car and Truck. Also, compare the speed of the two vehicles, Car and Truck and display “faster” or “slower” if Car is faster or slower than Truck. import java.util.*; class Vehicle{   int wheels;   double speed; } class Car extends Vehicle{   int pass;   void input(){    Scanner sc=new Scanner(System.in); System.out.println("Enter the car's details:\nNo. of wheels:");    wheels=sc.nextInt(); System.out.println("Speed of Car(Km/hr):");    speed=sc.nextDouble(); System.out.println("No. of passengers:");   ...

Why the World is Running Out of Computers

This April, 19 million new cars were sold in America — the highest level since 2005. But these weren’t just any old cars. Today’s Chevy Silverados and Ram 1500s are not quite the same as those sold a year or even a few months ago. Something very strange is happening a cross the industry.  Features, packages, even certain parts have suddenly disappeared from recently manufactured vehicles. An exceptionally observant buyer of a ‘21Silverado, for example, might notice their truck getting about one less mile per gallon than was advertised earlier this year on the same model. Recent Peugeot 308 hatchback owners, mean while, may be surprised to find the digital speedometer shown on TV replaced with an old-fashioned analog version. And the dashboard display on the Renault Arkana mysteriously got a little bit smaller.  It’s as if they’re playing a game: What tiny things can they change without anyone noticing? The actual explanation is a global shortage of semiconductors — the chips t...

Question: Write a java program that implements bank transactions using user defined exception.

Question: Write a java program that implements bank transactions using user defined exception. import java.util.*; class UDE{     public static void main(String ts7[]) throws MinimumBal {         Scanner sc= new Scanner(System.in);         double bal; System.out.println("Enter current balance:"); bal=sc.nextDouble(); System.out.println("Enter amount to withdrawal");         int n = sc.nextInt();         try {             if (bal<n)                   throw new MinimumBal("Account ae taka nei bhai !\nYour Current balance is "+bal);             else      System.out.print...