Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Finish the C + + program to balance chemical equations. It should prompt the user to Enter filename. After entering chemdata.txt , it should output

Finish the C++ program to balance chemical equations. It should prompt the user to Enter filename. After entering chemdata.txt, it should output the following:
EQ1: 4Al +3O2->2Al203
EQ2: Fe2(SO4)3+12KSCN ->2K3Fe(SCN)6+3K2SO4
EQ3: Cannot Balance
EQ4: Cannot Balance
Run again (Y/N): n
Contents of chemdata.txt:
4
21 Al O2 Al2O3
22 Fe2(SO4)3 KSCN K3Fe(SCN)6 K2SO4
11 CO2 CO
22 A B AB B
Code so far:
#include
#include
#include
using namespace std;
const int MAXELEM =30;
string names[MAXELEM];
int nElem =0;
long long linsys[MAXELEM][MAXELEM];
long long gcd(long long a, long long b)
{
if (b ==0)
return a;
return gcd(b, a%b);
}
int getIndex(string ename)
{
for(int i=0; i 0)
coeffs[index]= val;
else
coeffs[index]=1;
}
}
}
bool solve(long long a[MAXELEM][MAXELEM], int n, int m, long long soln[])
//
// solve linear system on n equations with m unknowns, checking
// for unsolvable systems
{
if (n < m)
return false;
for(int i=0; i=0; i--){
long long val = a[i][m];
for(int j=i+1; j> r >> p;
while (r >0){
icase++;
nElem =0;
for(int i=0; i> term;
for(int j=0; j> term;
for(int j=0; j

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Processing

Authors: David M. Kroenke, David Auer

11th Edition

B003Y7CIBU, 978-0132302678

More Books

Students also viewed these Databases questions

Question

6. Explain how to train managers to coach employees.

Answered: 1 week ago

Question

Why is the System Build Process an iterative process?

Answered: 1 week ago