Output 99 multiplication table from four directions by function

Source: Internet
Author: User
Package HHL; public class Jiujiu {public static void main (string[] args) {Zuoshang ();//Call the function of the multiplication table on the left is Zuoxia ();//Call Output the function of the lower-left multiplication table Shang ()//Call the function of the multiplication table on the right of the output youxia ();/Call output function of the multiplication table in the lower right () public static void Zuoshang ()//defines the function {for (int i=1;i<=9;i++ 
//The nested output of the For statement is 99 multiplication table {for (int j=1;j<=i;j++) {System.out.print (j+ "*" +i+ "="); 
System.out.printf ("%-4d", i*j); 
} System.out.println (); 
The public static void Zuoxia ()//defines the function {{System.out.println () of the lower-left multiplication table of the output; 
for (int i=9;i>=1;i–)//IBID. {for (int j=1;j<=i;j++) {System.out.print (j+ "*" +i+ "="); 
System.out.printf ("%-4d", i*j); 
} System.out.println (); The function {{for (int i=1;i<=9;i++)/+ of the multiplication table on the right of the public static void Youshang ()//is defined as {for (int. j=i;j<9;j++) {Syst 
Em.out.print ("T");
        for (int j=i;j>0;j--) {if ((i*j) <10) System.out.print ("" +j+ "*" +i+ "=" + (i*j) + "T");
    else System.out.print (+j+ "*" +i+ "=" + (i*j) + "T");
} System.out.println (); } SysTem.out.println (); The public static void Youxia ()//defines the function of the multiplication table in the lower right of the output {for (int i=9;i>0;i–)//IBID. {for (int j=0;j<9-i;j++) {System.ou 
T.print ("T"); for (int j=i;j>0;j--) {if (i*j) <10, System.out.print ("" +j+ "*" +i+ "=" +
            (i*j) + "T");
        else System.out.print (+j+ "*" +i+ "=" + (i*j) + "T");
    } System.out.println (); }
} 
}

The

results are as follows:

The knowledge point of this experiment:
1,for The Loop statement and the IF statement in the nested use. Define functions and Invocations in Java.
2, the mastery of the knowledge of the 99 multiplication table, and the attempts of various output methods.
The summary of this experiment:
1, the understanding and mastery of functions in Java,
2, the use of multiple loops to make the program more concise and understandable.
3, the lack of self, for the calculation of this aspect of the thinking is not very strong, and the software operation is not familiar, hope to improve next time.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.