//Assignment 2 anderbl Brent L. Anderson #include int inputnum, i, j, k, elsenumber; char outputchar; int main() { outputchar = '*'; // set default character while(inputnum != -2) { inputnum = 0; cin >> inputnum; if (inputnum < -6) // check to see if its valid { inputnum = -2; cout << "\nYou have entered an Invalid number, the first number in a pair cannot be < -6"; } else if (inputnum < -2) // check to see if its a special char { cin >> elsenumber; if (elsenumber < 0 || elsenumber > 255) //check to see if its valid { inputnum = -2; cout << "\nYou have entered an Invalid number, the second number in a special pair cannot be negative or greater then 255"; } } if (inputnum == -1) // next line cout << endl; else if (inputnum == -3) // change output character { outputchar = elsenumber; } else if (inputnum == -4) // draw box { for (j=1; j<=elsenumber; ++j) { for (k=1; k<=elsenumber; ++k) cout << outputchar; cout << endl; } } else if (inputnum == -5) // draw right triangle pointing up { for (j=1; j<=elsenumber; ++j) { for (k=1; k<=j; ++k) cout << outputchar; cout << endl; } } else if (inputnum == -6) // draw right triangle pointing down { for (j=1; j<=elsenumber; ++j) { for (k=1; k<=elsenumber - j + 1; ++k) cout << outputchar; cout << endl; } } for (i=1; i<=inputnum && inputnum > 0; ++i) // if nothing special and everything else is ok then print normal cout << outputchar; if (inputnum > -2) // if not special { cin >> inputnum; if (inputnum < 0) //check for a negative number in second number { inputnum = -2; cout << "\nYou have entered an Invalid number, the second number in a pair cannot be negative"; } } for (i=1; i<=inputnum && inputnum > 0; ++i) // fill spaces and ignor 2nd character if -1, -2, 0 is the first char cout << " "; } }