Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Molecular Weight Calculator (basic programming) create a program to calculate the molecular weight of a molecule with 2 elements in it (for example, H2O or
Molecular Weight Calculator (basic programming) create a program to calculate the molecular weight of a molecule with 2 elements in it (for example, H2O or CH4) The user will provide the atomic element symbols, atomic weights, and how many atoms of each element are in the molecule.
Next your program asks for three pieces of information about the first element in the molecule: 1. its chemical symbol (a single "word" like H, O, C, Na, or Cl); 2. its atomic weight (a number like 1.01, 16.00, 12.01,22.99); and 3. how many atoms of that kind are in the molecule (a counting number). Next it gets the same information for the second element. Your program then pauses again. Finally, your program prints out the result of its calculation. The result includes the formula for the molecule as well as the molecular weight. Note, the output may include some is where the formula would not. For example, the formula NaCl will be output as NalCll. That is fine. Also note that there is no (easy) way to get the numbers to print as subscripts, so do not bother to try. Just accept that the formula for water is going to look like H201. To calculate the weight of the molecule use the formula weight* count + weight x count where weight is the atomic weight of the first element, count is how many atoms of the first element are in the molecule, and similarly for weight and count- Next your program asks for three pieces of information about the first element in the molecule: 1. its chemical symbol (a single "word" like H, O, C, Na, or Cl); 2. its atomic weight (a number like 1.01, 16.00, 12.01,22.99); and 3. how many atoms of that kind are in the molecule (a counting number). Next it gets the same information for the second element. Your program then pauses again. Finally, your program prints out the result of its calculation. The result includes the formula for the molecule as well as the molecular weight. Note, the output may include some is where the formula would not. For example, the formula NaCl will be output as NalCll. That is fine. Also note that there is no (easy) way to get the numbers to print as subscripts, so do not bother to try. Just accept that the formula for water is going to look like H201. To calculate the weight of the molecule use the formula weight* count + weight x count where weight is the atomic weight of the first element, count is how many atoms of the first element are in the molecule, and similarly for weight and countStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started