Core Java| JSP| Servlets| XML| EJB| JEE5| Web Services| J2ME| Glossary| Questions? | Software Development
 

Calculate the Sum of three Numbers

This is simple java programming tutorial . In this section you will learn how to calculate the sum of three numbers by using three static variables.

Calculate the Sum of Three Numbers

                         

This is simple java programming tutorial . In this section you will learn how to calculate the sum of three numbers by using three static variables. 

Description of this program:

In this section we will see how to calculate three integer number . First of all define class name "StaticSum". For this we have defined three static variables of type int.  To assign the value of the numbers define a method main. Remember we are overloading the main method. This method will take three arguments.  The values will be added in the Addition method which we have declared in our program. Now call the main method. To get the values of the three numbers call the overloaded method main() inside main() method. To add those values call the Addition method which will return the integer value and the value will be displayed to the user by using the println() method of the System class.

Here is the code of this program

class StaticSum 
{
  public static int width;
  public static int height;
  public static int length;

  public static void main(int width1, int height1, int length1
  {
    width= width1;
    height=height1;
    length=length1;
  }
  public int Addition()
  {
    return(width+height+length);
  }
  public static void main(String arg[])
  {
    StaticSum staticSum = new StaticSum();
    StaticSum.main(12,14,15);
    int i= staticSum.Addition();
    System.out.println("value is="+ i);
  }
}

Download this Example

                         

» View all related tutorials
Related Tags: c convert io help this program to learn ram ear e il section in converting m ps pro s is

Leave your comment:

Name:

Email:

URL:

Title:

Comments:


Enter Code:

Audio Version
Reload Image
 

Note: Emails will not be visible or used in any way, and are not required. Please keep comments relevant. Any content deemed inappropriate or offensive may be edited and/or deleted.

No HTML code is allowed. Line breaks will be converted automatically. URLs will be auto-linked. Please use BBCode to format your text.

Add This Tutorial To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
 
Tell A Friend
Your Friend Name

 

 
Recently Viewed
Software Solutions
Search Tutorials

 

 
 

Home | JSP | EJB | JDBC | Java Servlets | WAP  | Free JSP Hosting  | Search Engine | News Archive | Jboss 3.0 tutorial | Free Linux CD's | Forum | Blogs

About Us | Advertising On RoseIndia.net  | Site Map

India News

Send your comments, Suggestions or Queries regarding this site at roseindia_net@yahoo.com.

Copyright © 2008. All rights reserved.