You are on page 1of 2

Mole Fraction:

/*
* 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 _molefraction;

/**
*
* @author user6
*/import java.util.Scanner;
public class _MoleFraction {

/**
* @param args the command line arguments
*/
public static void main(String[] args) {
Scanner input= new Scanner (System.in);
double mA, nA, nB, MWA, MWB ;

System.out.print ("mass fraction of A: ");


mA = input.nextDouble ( );
System.out.print ("MW of A: ");
MWA = input.nextDouble ( );
System.out.print ("MW of B: ");
MWB = input.nextDouble ( );

nA= (((mA/MWA)/((mA/MWA)+(1-mA/MWB))) ;
;
;

System.out.printf("mole fraction of A: "+"%5f",nA);

nB= 1-nA
System.out.printf("mole fraction of B: "+"%5f",nB);

}
}

You might also like