Tuesday, April 19, 2011

Chemistry: Compositional Percentage

Percentage of an element in a compund. Input total molar mass of each element.
e.g. O2 Has a mass of 32 g/mol.

-- CompNum --
:Input "NUMBER 2-5:",N
:Disp "ELEMENT"
:If N=5
:Then
:Prompt A,B,C,D,E
:A+B+C+D+EX
:Disp 100(A/X),100(B/X),100(C/X),100(D/X),100(E/X)
:End
:If N=4
:Then
:Prompt A,B,C,D
:A+B+C+DX
:Disp 100(A/X),100(B/X),100(C/X),100(D/X)
:End
:If N=3
:Then
:Prompt A,B,C
:A+B+CX
:Disp 100(A/X),100(B/X),100(C/X)
:End
:If N=2
:Then
:Prompt A,B
:A+BX
:Disp 100(A/X),100(B/X)
:End

No comments:

Post a Comment