0% found this document useful (0 votes)
40 views4 pages

Nama: Novian Eka Saputra Nim: 5160411022

The document contains source code for a Java program that calculates the volume and surface area of a cylinder. It defines classes for Circle and Cylinder that extend to calculate their geometric properties based on user inputted radius, diameter, and height values. The main method gets input, creates objects to set the values, and prints out the calculated volume and surface area of the cylinder.

Uploaded by

Yoga Aditya
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
40 views4 pages

Nama: Novian Eka Saputra Nim: 5160411022

The document contains source code for a Java program that calculates the volume and surface area of a cylinder. It defines classes for Circle and Cylinder that extend to calculate their geometric properties based on user inputted radius, diameter, and height values. The main method gets input, creates objects to set the values, and prints out the calculated volume and surface area of the cylinder.

Uploaded by

Yoga Aditya
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

Nama : Novian eka saputra

Nim : 5160411022

Source code Project


/*
* To change this license header, choose License Headers in Project
Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package projectt_praktek;
import java.util.Scanner;
/**
*
* @author ditoa
*/
public class ProjectT_Praktek {

/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here
double phi,d,t,r;
tabung obj_tabung = new tabung();
Scanner input = new Scanner(System.in);
try {
System.out.println("Input Diameter");
d = input.nextDouble();
System.out.println("Input Tinggi");
t = input.nextDouble();
System.out.println("Input Jari-Jari");
r = input.nextDouble();

obj_tabung.setD(d);
obj_tabung.setR(r);
obj_tabung.setT(t);
System.out.println("Volume Tabung :
"+obj_tabung.volumeTabung());
System.out.println("Luas Lingkaran :
"+obj_tabung.LuasLingkaran());
} catch (Exception e) {
System.out.println(""+e);
}
}

}
Source code Lingkaran
/*
* To change this license header, choose License Headers in Project
Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package projectt_praktek;

/**
*
* @author ditoa
*/
public class lingkaran {
private double phi=3.14;
private double r;

public double getPhi() {


return phi;
}

public void setPhi(double phi) {


this.phi = phi;
}

public double getR() {


return r;
}

public void setR(double r) {


this.r = r;
}

public double LuasLingkaran()


{
return this.phi*this.r*this.r;
}
}

Source code Tabung


/*
* To change this license header, choose License Headers in Project
Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package projectt_praktek;

/**
*
* @author ditoa
*/
public class tabung extends lingkaran{
private double phi=3.14;
private double d;
private double t;

public double getPhi() {


return phi;
}

public void setPhi(double phi) {


this.phi = phi;
}

public double getD() {


return d;
}

public void setD(double d) {


this.d = d;
}

public double getT() {


return t;
}

public void setT(double t) {


this.t = t;
}
public double volumeTabung()
{
return this.phi*this.d*this.d*this.t;
}
}
Output

You might also like