/*
1. Define a function to print the rectangle.
2. Define a function that prints the function of the 99 multiplication table.
*/
Class FunctionTest {
public static void Main (string[] args)
{
Draw (5,6);
Printhr ();
Draw (7,9);
Printhr ();
Print99 ();
}
/*
Define a function that prints the 99 multiplication table function
*/
public static void Print99 ()
{
for (int x=1;x<=9;x++)
{
for (int y=1;y<=x;y++)
{
System.out.print (y+ "*" +x+ "=" +y*x+ "\ t");
}
System.out.println ();
}
}
/*
Defines a feature that is used to print rectangles.
Ideas:
1, determine the result: no, because direct printing, so the return value type is void
2. Is there any unknown content? There are, two, because the rows and columns of the rectangle are indeterminate
*/
public static void Draw (int row,int col)
{
for (int x=0;x<row;x++)
{
for (int y=0;y<col;y++)
{
System.out.print ("*");
}
System.out.println ();
}
}
public static void Printhr ()
{
System.out.println ("----------");
}
}
Exercises on functions in Java Learning