#include #include #include using namespace std; void main () { int x0, x1, x2; //will hold the inputs float o; float w [3]; //array to hold perceptron weights float weightsum; bool error = 0; ifstream input; input.open("sigout.txt"); if (input.fail()) { cout << "file failed to open"; abort(); } for (int i = 0; i < 3; i++) input >> w[i]; x0 = -1; cout << "Please enter a value of 0 or 1 as input 1: "; cin>> x1; while (x1 != 1 && x1 != 0) { cout << "Please enter a value of 0 or 1 as input 1: "; cin>> x1; } cout << "Please enter a value of 0 or 1 as input 2: "; cin>> x2; while (x2 != 1 && x2 != 0) { cout << "Please enter a value of 0 or 1 as input 2: "; cin>> x2; } //find weighted sum of inputs and threshold values weightsum = x0 * w[0] + x1 * w[1] + x2 * w[2]; //determine output of perceptron if (weightsum > 0) o = 1; else o = 0; cout << "The result is: " << o << endl; input.close(); }