Answered step by step
Verified Expert Solution
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:
EQ: Al OAl
EQ: FeSOKSCN KFeSCNKSO
EQ: Cannot Balance
EQ: Cannot Balance
Run again YN: n
Contents of chemdata.txt:
Al O AlO
FeSO KSCN KFeSCN KSO
CO CO
A B AB B
Code so far:
#include
#include
#include
using namespace std;
const int MAXELEM ;
string namesMAXELEM;
int nElem ;
long long linsysMAXELEMMAXELEM;
long long gcdlong long a long long b
if b
return a;
return gcdb ab;
int getIndexstring ename
forint i; i
coeffsindex val;
else
coeffsindex;
bool solvelong long aMAXELEMMAXELEM 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;
forint i; i; i
long long val aim;
forint ji; j r p;
while r
icase;
nElem ;
forint i; i term;
forint j; j term;
forint j; j
Step 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