V22.0002 - ASSIGNMENT 5


You will write a program that writes a line on a 15x15 grid on the screen. The line is indicated by capital X's, the empty part of the grid is indicated by underscores ("_"). The user enters the beginning and ending coordinates of the line in terms of column and row, with the first entry being 1 and the last 15.

Specs:

  1. The program will read a pair of integers representing the starting coordinates.

  2. The program will read a pair of integers representing the ending coordinates.

  3. The program has to verify that the coordinates are legal, i.e.: within the range 1-15.

  4. The program has to be able to handle points given in any order (i.e., even if the "ending" point is in a row that proceeds the "starting" point).

  5. The line must resemble as much as possible a straight line. So if the line is slanted, the program will have to compute the correct column for each row so that amount of the shift is proportional to the position in the line (i.e.: say that you determine that the line should shift 1 column every 2 rows, the first and second row will have the X printed in the same column, the third and fourth row will have it one over, etc.).
Ex:
   Enter starting column and row: 2 2
   Enter ending column and row  : 9 9
                                           
   _______________                         
   _X_____________                         
   __X____________                         
   ___X___________                         
   ____X__________                         
   _____X_________                         
   ______X________                         
   _______X_______                         
   ________X______                         
   _______________                         
   _______________                         
   _______________                         
   _______________                         
   _______________                         
   _______________                         
                                           
   Enter starting column and row: 9 2      
   Enter ending column and row  : 2 9      
                                           
   _______________                         
   ________X______                         
   _______X_______                         
   ______X________                         
   _____X_________                         
   ____X__________                         
   ___X___________                         
   __X____________                         
   _X_____________                         
   _______________                         
   _______________                         
   _______________                         
   _______________                         
   _______________                         
   _______________                         

   Enter starting column and row: 2 2
   Enter ending column and row  : 8 13

   _______________
   _X_____________
   _X_____________
   __X____________
   __X____________
   ___X___________
   ___X___________
   ____X__________
   ____X__________
   _____X_________
   _____X_________
   ______X________
   _______X_______
   _______________
   _______________
Notes and Hints: