Latest Tutorials| Questions and Answers|Ask Questions?|Site Map

Home Answers Viewqa Java-Beginners program for factorial

Have Programming Question? Ask it here!

Suraj Arun Nalawade
program for factorial
1 Answer(s)      3 years and 10 months ago
Posted in : Java Beginners

how to set size of buttons on frame

View Answers

November 15, 2010 at 1:14 PM

Hi Friend,

Using the setPreferredSize(new Dimension(40,15)); method, you can set the button size in awt in java.

Here is your required code:

import java.awt.*;
import java.awt.event.*;
import java.util.regex.*;
class ButtonSize extends Frame{
    Label l;
        Label lab=new Label("Enter number to find its factorial: ");
        final TextField text=new TextField(20);
        Button b=new Button("Find");
        Panel p=new Panel();
        l=new Label();
        Panel pan=new Panel();
        b.addActionListener(new ActionListener(){
            public void actionPerformed(ActionEvent e){
                String input=text.getText();
    Pattern p = Pattern.compile("[A-Z,a-z,&%$#@!()*^]");
    Matcher m = p.matcher(input);
    l.setText("*Enter only numeric value!");
else if(input.equals("")){
    l.setText("*Enter value!");

    int num=Integer.parseInt(input);
    long fac=num;
    for(int i=num;i>1;i--){
    l.setText("Factorial Of Number "+input+" is: "+Long.toString(fac));
        b.setPreferredSize(new Dimension(40,15));     
    public static void main(String[] args){
        new ButtonSize();


Related Tutorials/Questions & Answers:
program for factorial
program for factorial  how to set size of buttons on frame
program for factorial
program for factorial  how to set size of buttons on frame
program on factorial of a given number in java
program on factorial of a given number in java  please tell me, how to write program on factorial of a given number in java
program on factorial of a given number in java
program on factorial of a given number in java  please tell me, how to write program on factorial of a given number in java
Factorial Program in Java
Factorial program in Java helps programmer to write factors of any given... exception". Example of Factorial program in Java: import*; class... execution of the program. BufferReader is defined under the Java I/O package
Write a program to calculate factorial of any given number
program to calculate factorial of any given number. First of all define a class... Factorial Examples - Java Factorial Example to calculate factorial of any.... As in this program we are going to insert certain instruction by creating buffer reader
Write a program to find a factorial in any given number
Write a program to find a factorial in any given number This programming tutorial will teach you how to write a factorial of any given number... that is equal to 24, and factorial of  0! is 0 always.Example : A program to find
find the factorial
find the factorial  how to find the factorial through the while loop...) { int value = 5, factorial = 1, temp = value; while (temp > 0) { factorial *= temp; temp
factorial of fibonacci
factorial of fibonacci   A code for the factorial of a fibonacci series. Example when the user enters 6, the fibonacci series is 8 and the factorial will be 8! or 8 x 7 x 6 x 5 x 4 x 3 x 2 x 1. So if the user enters the number 6
factorial - Java Beginners
factorial Example in Java  The factorial method is used frequently in probability problems. The factorial of a positive integer n (written as n!) is equal... class Factorial Example{ public static long factorial(int n){ if(n <
How to get factorial in mysql
How to get factorial in mysql  Hi, In order to improve the speed... alot for a function in mysql to find factorial numbers of a number and couldn't.... example: for 1155, the factorial numbers would be: 3, 5, 7, 11 Thank you
Calculate factorial of a number.
Calculate factorial of a number.  How to calculate factorial...; import; public class Factorial { public static...; } System.out.println(result); } } Description: - Factorial of any
Finding a Factorial using while loop
Finding a Factorial using while loop   ... are going to find out the factorial of 12 by using the while loop. In while loop... the scriptlet to calculate the factorial of 12. In the scriptlet we generally writes
factorial using recursive
factorial using recursive  can please give this code !i am going to do a factorial function using recursion definition and then . my professor told me that we are going to create a three screen. the first screen should be input
Finding a Factorial using while loop
; factorial* temp and keep on decreasing the value of temp by l. Code of the Program...Finding a Factorial using while loop      In this example we are going to find out the factorial of 12 by using
Calculate factorial Using Recursion
by using recursion in jsp. To make a program on factorial, firstly it must... a program on factorial by using recursion in jsp we are going to design a html page...Calculate factorial Using Recursion  
Java Swing Compute Factorial
Java Swing Compute Factorial In this section, we are going to find the factorial of a given number. Here an user is allowed to enter a number into the text field whose factorial is to be determined. On pressing the button the value
Calculating factorial in JRuby
Calculating factorial in JRuby   ... program" example you must be aware with the way to run JRuby program. Now in this example you will know to "Calculate Factorial in JRuby"
program  write a java program to input a no. and print wheather the no. is a special no or not. (special no. are those no whose factorial of the sum of digit of the no is same as the original
find factorial of any number using recursion
find factorial of any number using recursion  error in 14 line ; expected int rec( int a) ^ how to resolve this.please correct the code. import*; class Fact { public static void main(String[]arg)throws IOException
Java Program - Java Beginners
Java Program  Write a program to find the Factorial of a number using Recursion. Factorial can be defined as Factorial(n) = 1 * 2 * 3 ‚?¶.* (n-1... FactorialUsingRecursion(); System.out.println("Factorial of 2 = " + f.findFactorial(2
java program code
java program code  can any one write a program (class) which will have two methods Fibonacci and Factorial, which will be a void and a return respectively. i will be glad if it can have a good display results
program  any program of hotel or school management
program  program of jdbc using ms access for creating table
program  write a javascript program to create a application form with validation
program  write a html program in show table and this word in box
program  write a program different between to dates in terms of days in java
program   Write a program to find the difference between sum of the squares and the square of the sums of n numbers
program  write a program reversee a string. input-hi this is roseindia output-roseindia is this hi
program  develop a servlet to insert the data in the database from our program in the table stored in the database
program  WAP a java program to form 1/2+3/4+5/6+7/8 series
program   An old-style movie theater has a simple profit program. Each customer pays $5 per ticket. Every performance costs the theater $20, plus $.50 per attendee. Develop the program calculateTotalProfit that consumes
program  explanation of program on extending thread class   Hi Friend, Please go through the following link: Java Threads Thanks
program  Develop the program calculateCylinderArea, which accepts radius of the cylinder's base disk and its height and computes surface area of the cylinder
program  Develop a program that computes the distance a boat travels across a river, given the width of the river, the boat's speed perpendicular to the river, and the river's speed. Speed is distance/time, and the Pythagorean
program  how to improve programming skills plss tell some tips..i am understanding concepts but unable to write program so,pls give some guideness plsss
Program  a program to prove that default constructor of super class is available to subclass by default. Define a parameterize constructor for super class to store name = ‚??Tommy‚?? age=‚??23‚?? and call this constructor
Program  a program to create two classes Commercial and Domestic. Override the method calculatebill() of Commercial class(Rs.8 per unit) into Domestic class(Rs 6 per unit) to compute electricity bill for both classes
program  no i want a program that shows how merge sort algorithm works in graphical representations like numbers are taken in circles and computation... in rectangles or circles wat ever it may be. the theme of program is to show algorithm
program  . Develop a program that accepts an initial amount of money (called the principal), a simple annual interest rate, and a number of months will compute the balance at the end of that time. Assume that no additional
program  Write a JSP Program, which displays a web page containing the name of the Courses, Courses being offered currently, number of students enrolled in each course, new courses to be offered, eligibility criteria for taking
program  i want a progra in java to print a sentence in alphabetic order, taking the input from the user.the program should writen without using the array for example : if input= this is a cat then output sould = a cat
program  Utopias tax accountants always use programs that compute income taxes even though the tax rate is a solid, never-changing 15%. Define the program calculateTax which determines the tax on the gross pay. Define
program  Write a JSP Program, which displays a web page containing two web links one for your profiling and other for the schedule of theory of practical classes of your Batch. When one click on link for getting your profile
program  Write a program to print details of a week for a particular day using array of objects Integer and String. OUTPUT: First Day of Week is Monday Second Day of Week is Tuesday Third Day of Week is Wednesday Forth Day
Printing Table in JRuby
studied how to run program in JRuby and to calculate factorial in JRuby. Now... this program execute this JRubyTable.rb with jruby command. This will ask for a value to calculate factorial and generate result according to given value. Output
Write a program in java...
to enter an integer number. Write a program in java to find the factorial...Write a program in java...  Hi, friends Please, can you help me? Q1: Write a program in java to simulate a calculator. Your program should take two
Series program in Java - Java Beginners
Series program in Java  Wap to print the series and find the sum:- 1... from "+begin+" to "+end+" : "+obj.series+result); } public int factorial...=start;i<=end;i++){ fact = factorial(i); sum = fact+i; series
program calculateCylinderVolume
program calculateCylinderVolume  program calculateCylinderVolume
java program for
java program for   java program for printing documents,images and cards