//constructor java memakai parameter
package lingkaranb;
class lingkaran
{
double phi;
double r;
lingkaran (double p,double r1)
{
phi=p;
r=r1;
}
double hitungling()
{
return (phi*r*r);
}
}
/**
*
* @author Rizal
*/
public class LingkaranB {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here
lingkaran L1,L2;
L1=new lingkaran(3.14,10);
L2=new lingkaran(3.14,3);
System.out.println("lingkaran1= "+L1.hitungling());
System.out.println("lingkaran2= "+L2.hitungling());
}
}
package lingkaranb;
class lingkaran
{
double phi;
double r;
lingkaran (double p,double r1)
{
phi=p;
r=r1;
}
double hitungling()
{
return (phi*r*r);
}
}
/**
*
* @author Rizal
*/
public class LingkaranB {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here
lingkaran L1,L2;
L1=new lingkaran(3.14,10);
L2=new lingkaran(3.14,3);
System.out.println("lingkaran1= "+L1.hitungling());
System.out.println("lingkaran2= "+L2.hitungling());
}
}
Hasil Akhir :
0 komentar:
Posting Komentar