Advertisement
Felanpro

Calculating limiting reagent

Feb 7th, 2019
167
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.54 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7.     /*
  8.     Litet program som kalkylerar den begränsande reaktanten av två ämnnen utifrån
  9.     förhållandet och mängden i mol.
  10.     */
  11.    
  12.     double ratio_component_chemical_one;
  13.     double ratio_component_chemical_two;
  14.    
  15.     cout << "Type in the ratio between the two chemicals: ";
  16.     cin >> ratio_component_chemical_one;
  17.     cout << ":";
  18.     cin >> ratio_component_chemical_two;
  19.    
  20.     //-----------------------------------------
  21.    
  22.     cout << "Now insert the amount of mole units you have of each chemical - " << endl;
  23.    
  24.     double number_of_moles_chemical_one;
  25.     double number_of_moles_chemical_two;
  26.    
  27.     cout << "First chemical: " << endl;
  28.     cin >> number_of_moles_chemical_one;
  29.    
  30.    
  31.     cout << "Second chemical: " << endl;
  32.     cin >> number_of_moles_chemical_two;
  33.    
  34.     //Uträkning
  35.    
  36.     double expected_ratio_component = ratio_component_chemical_two/ratio_component_chemical_one;
  37.    
  38.     if(number_of_moles_chemical_one * expected_ratio_component == number_of_moles_chemical_two)
  39.     {
  40.         cout << "There's no limiting chemical!" << endl;
  41.     }
  42.     else if(number_of_moles_chemical_one * expected_ratio_component > number_of_moles_chemical_two)
  43.     {
  44.         cout << "The second chemical is the limiting chemical!" << endl;
  45.     }
  46.     else if(number_of_moles_chemical_one * expected_ratio_component < number_of_moles_chemical_two)
  47.     {
  48.         cout << "The first chemical is the limiting chemical!" << endl;
  49.     }
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement