// Rpw Rduction Algorythm.cpp : Defines 

//     the entry point for the console applicat

//     ion.

//solves a linear system whith a ordered

//     pair solution

#include "stdafx.h"

#include "iostream.h"

int intboolfalsetrue

enum CHOICE {again = 1,no};

int main(int argc, char* argv[])

    {

     cout << "****** Produced by Daniel G. From Alaska ******\n";

     cout << "****** Use it. Charish it. Speed up your Homework.\n\n";

    

     int choice; //input for loop

     int fQuit = false; //setup for loop

     // create, input values

     double aOne, aTwo, aThree, bOne, bTwo, bThree,Y,X; //variables

     while(!fQuit)

         {

         //input information

         cout << "Enter a(1), a(2), and a(3) from the equation a(1)x+a(2)y=a(3)\n";

         cout << "a(1): ";

         cin >> aOne;

         cout << "a(2): ";

         cin >> aTwo;

         cout << "a(3): ";

         cin >> aThree;

         cout << "\nEnter b(1), b(2), and b(3) from the equation b(1)x+b(2)y=b(3)\n";

         cout << "b(1): ";

         cin >> bOne;

         cout << "b(2): ";

         cin >> bTwo;

         cout << "b(3): ";

         cin >> bThree;

        

         //check for non odered pair system

         if (aOne==0)

             {

             cout << "Invalid entry for a(1): Cannot be 0\n";

             goto end;

             }

             //Row-Reduction-Algorythm procedure

             aTwo = aTwo/aOne;

             aThree = aThree/aOne;

            

             bTwo = bTwo + ( -1 * aTwo * bOne);

             bThree= bThree + (-1 * aThree * bOne);

             if (bTwo ==0)

                 {

                 cout << "Answer not a single ordered pair.\n";

                 goto end;

                 }

                 Y=bThree / bTwo;

                 X= aThree - (aTwo * Y);

                 cout << "Solution: (" <

                end:  cout << "\nRepeat? (1) yes (2) no\n";

                  cin >> choice;

                  switch (choice)

                      {

                      case again:

                      break;

                      case no:

                      fQuit = true;

                      break;

                      default:

                      cout << "Invalid.";

                      fQuit = true;

                      break;

                     }

                     }

                    return 0;

                }