find the area and circumference of a circle (JAVA)

hello bloggers and programmers, in this post I will discuss about programming with java by using the class function.

the example program I would create a program to find the area and circumference of a rectangle.

to see more let’s look at the source code.

first made ​​its main function java
and then we create a new java class with the name rtc.java (java class)

codex
/ *
* To change this template, choose Tools | Templates
* And open the template in the editor.
* /

package rectangle;

/ **
*
* @ Author Foead
* /
rtc {public class
public float width;
public float Long;

public rtc () {
}

public rtc (float width, float Long) {
this.width = width;
this.Long = Long;
}

public float getLong () {
Long return;
}

public void setLong (float Long) {
this.Long = Long;
}

public float getWidth () {
return width;
}

public void setWidth (float width) {
this.width = width;
}
}

after completion, then fill in the value of the class that we have created is the main function of existing java

/ *
* To change this template, choose Tools | Templates
* And open the template in the editor.
* /

package rectangle;

/ **
*
* @ Author Foead
* /
public class Main {

/ **
* @ Param args the command line arguments
* /
public static void main (String [] args) {
/ / TODO code application logic here
rtc rtc x = new ();

x.setLong (4);
x.setWidth (6);

System.out.println (“find the area and circumference of a rectangle.”);
System.out.println (“width” x.width +);
System.out.println (“long” + x.Long);
System.out.println (“broad result is” + x.Long * x.width);
System.out.println (“roving result is” +2 * (x.Long * x.width));
}

}

then run.

its output is the result:
run:
find the area and circumference of a rectangle.
width6.0
long4.0
broad result is24.0
Roving result is20.0
BUILD SUCCESSFUL (total time: 0 seconds)

This program is run with netbeans 6.5

jst try. : D

thank you

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: