I'm writing a program that displays a box of any given size. There are width & height limits. The program should process only one input case (legal or not).
This is my code so far:
Code:
I can get the box to print.Code:_________________________________________________ #include <iostream> using std::cout; using std::cin; using std::endl; int main() { char character; int width =79, height = 20; cout << "enter the character, width and height (eg. * 6 3:)"; cin >> character >> width >> height; for (int i = 1; i <= height; i++) { for (int j = 1; j <= width; j++) if ( i == 1 || i == height) cout<< character; else cout<<"ERROR: The height must be between 1 and 20 inclusive!"; cout<<"\n"; if (j == 1 || j == width ) cout<< character; else cout<<"ERROR: The width must be between 1 and 79!"; cout<<"\n"; } return 0; } _________________________________________________
However when I try to set height and width limits, the program does not do what it is suppose to do.
Also, how would you print the box with a hollow center.
Any help would be great!
Thanx!
CODE TAGS added by Hammer



LinkBack URL
About LinkBacks


