In: Computer Science
Write a full program that solves the following equation and displays the value for x and y: 3.4x+50.2y=44.5 2.1x+.55y=5.9
// C++ code
#include <iostream>
#include <string>
#include <fstream>
#include <stdlib.h>
#include <math.h>
#include <vector>
#include <iomanip> //
std::setprecision
using namespace std;
int main()
{
double a1,b1,c1;
double a2,b2,c2;
a1 = 3.4;
b1 = 50.2;
c1 = 44.5;
a2 = 2.1;
b2 = 0.55;
c2 = 5.9;
b1 = b1 /a1;
c1 = c1 /a1;
a1 = 1;
b2 = b2 /a2;
c2 = c2 /a2;
a2 = 1;
double y = (c1-c2)/(b1-b2);
double x = (c1-y*b1);
cout << "x: " << x <<
endl;
cout << "y: " << y <<
endl;
return 0;
}
/*
output:
x: 2.6239
y: 0.70874
*/