View Single Post
Old 03-21-2005, 04:37 PM   #1 (permalink)
C++noob
Registered User
 
Join Date: Mar 2005
Posts: 4
C++noob is on a distinguished road
Help with a simple program

Hi guys, Im taking an intro to programming course, because I've always been good at working with computers, unfortunatley I suck!!!! at programming, and thus I suck at this course.

I need help with a homework assignment very badly. Im not asking for you to do my homework, but any hints are very very welcome.

The assignment is as follows:

Quote:
Write a program that prints a checkerboard of given dimensions. The provided main function prompts the user for the size of the board (note that x and y dimensions do not have to be equal) and for the size of individual squares (again, the dimensions of a square do not have to be equal). The following is an example of 8 x 8 board made out of 5 x 3 squares:

( I couldn't get the chest board he made to copy/paste properly)


The printout must include centered top and side labels for columns and rows. The size of the board will not exceed 9 x 9 and both dimensions of a square must be odd.

The program must check whether the parameters entered by a user are valid (e.g., greater than zero, a board size greater than 9, or a square dimension is not odd). If any of the parameters is invalid, the program should print an error message and exit.

Add your code to the provided main function. Except for adding your code, you must not modify the given code. You can either download the code or copy it to you account using the following Unix command (note the dot at the end of the line):
The code that he provides us is

Quote:
#include <iostream>
using namespace std;

// prototype

int printBoard(int x, int y, int xSq, int ySq);
// Prints x times y "chess" board using xSq times ySq squares.
// Returns a nonzero value if an invalid param specified
// zero otherwise.

// your code goes here

int main () {
int x, y, xSq, ySq;

cout << "Enter horizontal dimension of the board : ";
cin >> x;
cout << "Enter vertical dimension of the board : ";
cin >> y;
cout << "Enter horizontal size of a square : ";
cin >> xSq;
cout << "Enter vertical size of a square : ";
cin >> ySq;

if (printBoard(x,y,xSq,ySq))
cout << "Invalid parameter\n";

return 0;
}
Once again, Im not asking for anyone to do my work(though I wouldn't mind ) ,I just need any hints or advice about how to tackle this. I just don't have the right kind of my mind to be a programmer.

Thanks,

Josh/C++ noob
C++noob is offline   Reply With Quote