Amino acids in proteins are composed of atoms of oxygen, carbon, nitrogen, sulfu
ID: 3552243 • Letter: A
Question
Amino acids in proteins are composed of atoms of oxygen, carbon, nitrogen, sulfur, and hydrogen with atomic weights as below:
Oxygen: 15.9994
Carbon: 12.011
Nitrogen: 14.00674
Sulfur: 32.066
Hydrogen: 1.00794
Write a program that asks user to enter chemical formula for an amino acid and outputs (displays) the molecular weight of that amino acid. For example: if alanine is entered as O2C3NH7 then the output must be:
The molecular weight of O2C3NH7 is : 89.09412
Hand calculation: O: 2*15.9994 + C: 3*12.011 + N: 1*14.00674 + H: 7*1.00794 = 89.09412
Write this as a user defined function.
You must incorporate error checking in the input and display if found. Also user must get to input correct data if an error occurs in the input.
Some of the type errors a user makes could be:
1. entering a letter that is not in the chemical composition
2. entering new line character before entering the data
3. entering data with a single quote (one to begin and one to end)
The errors may not be limited to the above and you may discover new ones. Regardless, you must consider which ones could be more likely to occur.
Explanation / Answer
take hint from below similar question
Given a cell array of chemical formulas, or a structure array of atomic representations,molweightcomputes a corresponding vector of molecular weights.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.