- #1
asz304
- 108
- 0
Homework Statement
http://www.engr.mun.ca/~markevans/engr1020/Eng1020Labs/Assignments/Entries/2010/11/16_Assignment_8__Computers!_Science!.html
The Attempt at a Solution
I'm not sure how to use array in this assignment, and I'm not sure where to use switch statement...
My Code
Code:
#include <iostream>
#include <string>
#include <cstdlib>
using namespace std;
/***************************************************************************************************
*
* @params: none
*
* @descript: Asks inputs from the user
*
* @returns: 0 for succession.
*
***************************************************************************************************/
int main(){
char C = "12.0107";
char c = "12.0107";
char O = "15.9994";
char H = "1.0079";
char N = "14.0067";
string molecule;
int index, valueC;
float molarMass;
while ( molecule != "q" || molecule!= "Q"){
int moleculeValues [4] = { 12.0107, 15.9994, 1.0079, 14.0067 };
cout << "Enter the organic molecule: ";
getline (cin, molecule);
indexC = molecule.find ( 'C', 0 );
int carbon = atoi (C);
indexO = molecule.find ( 'O', 0 );
int oxygen = atoi ( O );
indexN = molecule.find ( 'N', O );
int nitrogen = atoi ( N );
molarMass = carbon + oxygen + hydrogen + nitrogen;
}
return 0;
}
Could you please tell me where to use array? thanks