Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

Chemical Reaction X: A Program to Calculate Reaction Stages and Energy, Study notes of Computer Science

A c++ program for calculating the energy output of a chemical reaction named reaction x during its two stages. The program takes the pressure as input and outputs the catalyst type, pressure, molarity, and energy for each stage. The energy is calculated using the cosine and sine functions.

Typology: Study notes

2010/2011

Uploaded on 05/12/2011

malsooj
malsooj 🇺🇸

2 documents

1 / 2

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Mohammad Al-Sooj
// Mohammad Al-Sooj
// Compute the chemical reaction called Reaction X
#include <iostream>
#include <math.h>
using namespace std;
void Intro (void);
void Inputs (double &Pressure);
void Results1 (double Pressure);
void Results2 (double Pressure, double &Molarity);
double StageA (double Pressure);
double StageB (double Pressure, double Molarity);
int main()
{
double Pressure, Molarity;
Intro ();
Inputs (Pressure);
Molarity = StageA (Pressure);
Results1 (Pressure);
StageB (Pressure, Molarity);
Results2 (Pressure, Molarity);
return 0;
}
void Intro (void)
{
cout << "Welcome to Forever Future Laboratories." << endl;
cout << "This program tests the new experimental chemical reaction \"Reaction X\".";
cout << endl << endl;
}
void Inputs (double &Pressure)
{
cout << "Enter the Pressure in Millibars: ";
cin >> Pressure;
}
pf2

Partial preview of the text

Download Chemical Reaction X: A Program to Calculate Reaction Stages and Energy and more Study notes Computer Science in PDF only on Docsity!

Mohammad Al-Sooj // Mohammad Al-Sooj // Compute the chemical reaction called Reaction X #include #include <math.h> using namespace std; void Intro (void); void Inputs (double &Pressure); void Results1 (double Pressure); void Results2 (double Pressure, double &Molarity); double StageA (double Pressure); double StageB (double Pressure, double Molarity); int main() { double Pressure, Molarity; Intro (); Inputs (Pressure); Molarity = StageA (Pressure); Results1 (Pressure); StageB (Pressure, Molarity); Results2 (Pressure, Molarity); return 0; } void Intro (void) { cout << "Welcome to Forever Future Laboratories." << endl; cout << "This program tests the new experimental chemical reaction "Reaction X"."; cout << endl << endl; } void Inputs (double &Pressure) { cout << "Enter the Pressure in Millibars: "; cin >> Pressure; }

Mohammad Al-Sooj void Results1 (double Pressure) { cout << "Stage #1" << endl; cout << "Catalyst Type: Powdered" << endl; cout << "Pressure: " << Pressure << " Millibars" << endl; cout << "Molarity: 1066" << endl << endl; cout << "The energy is " << StageA(Pressure) << " Kantrons" << endl << endl; } void Results2 (double Pressure, double &Molarity) { cout << "Stage #2" << endl; cout << "Catalyst Type: Liquid" << endl; cout << "Pressure: " << Pressure << " Millibars" << endl; cout << "Molarity: " << Molarity << endl << endl; cout << "The energy is " << StageB(Pressure, Molarity) << " Kantrons" << endl << endl; } double StageA (double Pressure) { double Energy; const double Molarity = 1066; const double Luminosity = 7.0/6.0; Energy = Luminosity * ( cos(Pressure + Molarity) / (sin(Pressure) + sin(Molarity)) ); return Energy; } double StageB (double Pressure, double Molarity) { double Energy; const double Luminosity = 11.0/6.0; Energy = Luminosity * ( cos(Pressure + Molarity) / (sin(Pressure) + sin(Molarity)) ); return Energy; }