# Cramer's Rule variable locations

• (2 Pages)
• 1
• 2

## 18 Replies - 2759 Views - Last Post: 08 February 2013 - 05:47 PMRate Topic: //<![CDATA[ rating = new ipb.rating( 'topic_rate_', { url: 'https://www.dreamincode.net/forums/index.php?app=forums&module=ajax&section=topics&do=rateTopic&t=311491&amp;s=eeb9100573701c792458012409de6af3&md5check=' + ipb.vars['secure_hash'], cur_rating: 0, rated: 0, allow_rate: 0, multi_rate: 1, show_rate_text: true } ); //]]>

### #16 codescout

Reputation: 0
• Posts: 46
• Joined: 02-October 12

## Re: Cramer's Rule variable locations

Posted 08 February 2013 - 03:37 PM

Will post it soon, tied up for a minute.

This post has been edited by codescout: 08 February 2013 - 03:37 PM

### #17 codescout

Reputation: 0
• Posts: 46
• Joined: 02-October 12

## Re: Cramer's Rule variable locations

Posted 08 February 2013 - 04:17 PM

Hope that I am at least close to the solution.

```#include <iostream>
#include <cmath>
#include <cstring>
using namespace std;

class LinearEquation
{
private:
double a, b, c, d, e, f, x, y, isSolvable;

public:
LinearEquation(double a, double b, double c, double d, double e, double f, double x, double y, bool isSolvable);

double getA(double);
double getB(double);
double getC(double);
double getD(double);
double getE(double);
double getF(double);
double getX(double, double, double, double);
double getY(double, double, double, double);
bool isSolvable(double, double, double, double);
};

double LinearEquation::getA(double){
return a;
}
double LinearEquation::getB(double){
return b;
}
double LinearEquation::getC(double){
return c;
}
double LinearEquation::getD(double){
return d;
}
double LinearEquation::getE(double){
e =((a*x) + (b*y));
return e;
}
double LinearEquation::getF(double){
f = ((c*x) + (d*y));
return f;
}
bool LinearEquation::isSolvable(double, double, double, double){

bool isSolvable = true;
if((a*d)-(b*c) != 0){

return isSolvable;
}
else {
return false;
}
}
double LinearEquation::getX(double, double, double, double){
double x =((e*d)-(b*f)/(a*d)-(b*c));
return x;
}
double LinearEquation::getY(double, double, double, double){
double y = ((a*f)-(e*c)/(a*d)-(b-c));
return y;
}

int main()
{
double a;
double b;
double c;
double d;
double e;
double f;
double x;
double y;
bool isSolvable;

LinearEquation(double, double, double, double, double, double, double, double, bool);

double variableArray[6] = {a, b, c, d, e, f};

cout<<"Enter a, b, c, d, e, f: ";
for(int i = 0; i < 6; i++){
cin >> a >> b >> c >> d >> e >> f;

if (isSolvable(a, b, c, d)){
cout <<"x is "<< (&LinearEquation::getX) <<" and y is " << (&LinearEquation::getY);
}
else{(&LinearEquation::isSolvable);{
cout <<"The equation has no solution.";
}
}
return 0;
}
}
```

### #18 jimblumberg

Reputation: 5494
• Posts: 17,070
• Joined: 25-December 09

## Re: Cramer's Rule variable locations

Posted 08 February 2013 - 04:50 PM

I think you have too many parameters in your constructor. You shouldn't need the x,y and issolvable variables. These variables will be calculated when required. Also your getx(), gety(), issolvable() functions probably don't need any parameters, they will use the class member variables.

Also when you define your functions you should name the parameters. This will help with documenting your class.
```void yourFunction(int variableName);
```

You also don't need any arrays in this program, you are using separate variables not arrays.

When you try to call a function you need the variable names not the variable types.

When you implement your functions you must supply variable names to this function.
```double LinearEquation::getX(double, double, double, double){
```

The above snippet is incorrect, you need to provide names for the variables to be used in the function along with the type of variable.
```void someFunction(int value){
```

There are probably many other things wrong with your program, you should probably re-read the function tutorials contained in my signature along with the links about classes from previous posts.

Jim

### #19 codescout

Reputation: 0
• Posts: 46
• Joined: 02-October 12

## Re: Cramer's Rule variable locations

Posted 08 February 2013 - 05:47 PM

This alone has cleared up alot. Many of the tutorials define differently and I was not sure which one would fit my problem. Thank you so much. Will keep reading.

• (2 Pages)
• 1
• 2

 .related ul { list-style-type: circle; font-size: 12px; font-weight: bold; } .related li { margin-bottom: 5px; background-position: left 7px !important; margin-left: -35px; } .related h2 { font-size: 18px; font-weight: bold; } .related a { color: blue; }