| |
L.A.10.1 - Pictures | page 8 of 10 |
Assignment:
Write a method that takes in, through its parameters, the number of rows and columns to print in a multiplication table.
There must be a margin of row and column headings for the table.
The answer columns should be separated by a field-width of 5 columns.
A blank line should be inserted between the column heading and the first row of the table.
A precondition of the procedure is that the value of the row or column will be from 1..12.
Sample run output for printTable(4,6) :
1 2 3 4 5 6
1 1 2 3 4 5 6
2 2 4 6 8 10 12
3 3 6 9 12 15 18
4 4 8 12 16 20 24
__________________________________________
Write another method to print the following pyramid pattern of stars. If the number of lines = 5, then:
*
***
*****
*******
*********
Such a method should take in, through its parameter list, the number of lines to print. The precondition of this method, lines <= 30.
Instructions:
The main method will consist of only 4 method calls separated by readLine() calls.
public class PicturesTest
{
public static void main (String[] args)
{
Pictures pic = new Pictures();
ConsoleIO keyboard = new ConsoleIO();
String get;
pic.printTable(4,6);
get = keyboard.readLine(); // freezes the output screen to see the picture
pic.printTable(11,12);
get = keyboard.readLine();
pic.pyramid(10);
get = keyboard.readLine();
pic.pyramid(25);
get = keyboard.readLine();
}
}
The readLine() between the four method calls will hold the picture until a return key is entered.
Your source code must include a pseudocode version of each method. Write your pseudocode above your actual code as documentation. Please follow the process and develop your pseudocode first, then translate it to code. You need to practice this system of problem solving on relatively easy problems so that you can apply it to more difficult problems.
|