CALCULATE CYLINDER AND RECTANGLE USING INTERFACE AND INHERITANCE interface Area { float pi=3.14f; float compute(float a, float b); } class Rectangle implements Area { public float compute(float a,float b) { return (a*b); } } class Cylinder implements Area { public float compute(float a,float b) { return (pi*a*b); } } class Exe { public static void main(String a[]) { Area ob; ob=new Rectangle(); System.out.println("RECTANGLE: "+ob.compute(22.5f,77.3f)); ob=new Cylinder(); ...
SUM OF SERIES : document.write("it works Sum of series 1 2 3 4 5<br>"); var sum = 0; [1,2,3,4,5].forEach(function(number) { sum += number; }); document.write("SUM= "+sum +"<br>"); FACTORIAL: <!DOCTYPE html> <html> <head><title> </title></head> <style type="text/css"> *{ background: #d2d5d8 ; } h1{ display: flex; justify-content: center; align-items: center; } ::selection{ background-color: #dddd2a;color:black;} </style> <body><h1> <script type="text/javascript"> a= parseInt(prompt("Find Factorial: ")); // set factorial ans f as 1 f=1; // if given no is positive if(a>0) { // decrementing loop for(i=a;i>0;i--){ f= f * i; ...
Comments
Post a Comment