2:42 am - Tuesday November 13, 2018

Java Example Program to find flat Area cone

CANDID INDUSTRIAL TRAINING -- CHENNAI
Corporate Training for Experienced Candidate
Struts | Hibernate | Spring | Java / J2EE
SOAP | RestFull | Design Pattern | more...
Ph: +91 72000 69003
137b, 2nd st, shanthi nagar, Chrompet, Chennai -600044

/**
@author:Candidjava
@discription:FlatAreaCone
@To find the value of Flatareacone
*/
import java.lang.Math; //To import the math package

public class Sample {
int r, R, h; // to declare the int value
double SA; // to declare SA
final double pi = 3.14;

Sample(int r, int R, int h) {
this.R = R;
this.h = h;
this.r = r;
}

void flatAreaCone() // using constructor
{
SA = Math.sqrt(pi * (R + r) * (((R - r) ^ 2) + (h ^ 2))); // To
// calculate
// SA
System.out.println(SA); // print the value of SA
}

public static void main(String arg[]) {
Sample s1 = new Sample(2, 5, 3); // create the object s1 to pass the
// value
s1.flatAreaCone();
}
}

Output:

    6.6302

Filed in: Z-A All Java Codes

Comments are closed.