/**
*
* @author TRACER
*/
public class lat5 {
public static final double AVOGADRO = 6.02e23;
public static final int CARBON = 12;
public static final int HYDROGEN = 1;
private double mass = 0.0;
private int nrOfHYDROGEN = 0;
private int nrOfCARBON = 0;
private int massperAVOGADRO = 0;
private double molecule = 0.0;
public lat5(double mass, int nrOfHYDROGEN, int nrOfCARBON) {
this.mass = mass;
this.nrOfCARBON = nrOfCARBON;
this.nrOfHYDROGEN = nrOfHYDROGEN;
calcMolecules();
}
public void calcMolecules() {
massperAVOGADRO = (nrOfCARBON * CARBON) + (nrOfHYDROGEN) * HYDROGEN;
molecule = (mass / massperAVOGADRO) * AVOGADRO;
}
@Override
public String toString() {
String str =
"HYDROCARBON" + "\n"
+ "Rumus HYDROCARBON, C" + nrOfCARBON + "H" + nrOfHYDROGEN + "\n"
+ "MASSA per AVOGADRO : " + massperAVOGADRO + "\n"
+ "MASSA :" + mass + "gram\n"
+ "JUMLAH mol :" + molecule;
return str;
}
static void test() {
lat5 c = new lat5(30, 2, 6);
System.out.println(c);
}
public static void main(String[] args) {
test();
}
}
---------------------------------------------------------------------------------------------------------------
wishin to be a be man
No comments:
Post a Comment