class Demo{
double height;
double base;
double area(){
return 0.5*base*height;
}
}
public class Main{
public static void main(String args[]){
Demo dm = new Demo();
dm.base = 10.5;
dm.height = 12.0;
double res = dm.area();
System.out.println("The area of a Triangle is: " + res);
}
}
Method using return type
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment