Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Enter atomic symbols in single quotes. When the symbol is a single letter, prece

ID: 3546967 • Letter: E

Question

Enter atomic symbols in single quotes.

When the symbol is a single letter, precede the letter with a space.

Enter the atomic symbol ' K'

Are there more elements? y/n y

Enter the atomic symbol 'Al'

Are there more elements? y/n Y

Enter the atomic symbol 'Si'

Are there more elements? y/n y

Enter the atomic symbol ' O'

Are there more elements? y/n n


For element K

Please enter the weight 39.098

Enter the number of these atoms in the compound 4


For element Al

Please enter the weight 26.982

Enter the number of these atoms in the compound 4


For element Si

Please enter the weight 28.086

Enter the number of these atoms in the compound 1


For element O

Please enter the weight 15.999

Enter the number of these atoms in the compound 8



The total weight is 420.398

symbol weight number wt %

K 39.098 4 37.2009

Al 26.982 4 25.6728

Si 28.086 1 6.6808

O 15.999 8 30.4454

Explanation / Answer

clear all; close all; clc; s='dummy'; next='y'; n=1; atoms=[]; while next=='y'|| next=='Y' s = input('Enter the atomic symbol: ','s'); atoms= [atoms,s]; n=n+2; next=input('Are there more elements ? : ','s'); end
n=n-2; for i=1:2:n w=input(['Enter the atomic weight of ' atoms(i) atoms(i+1) ' : ']); atw(i)=w;
c=input('Enter the number of these atoms in the compound : '); atc(i)=c; end
aw=0; for i=1:2:n; aw=aw+atw(i)*atc(i); end
fprintf(['The Total Weight is : ' num2str(aw) ' ']);
for i=1:2:n wtp(i)=(atw(i)*atc(i)*100)/aw; end
for i=1:2:n disp([atoms(i),atoms(i+1) ,' ',num2str(atw(i)),' ',num2str(atc(i)),' ',num2str(wtp(i))]); %disp(table(i)); end