My Java Learning Path's cyclic learning application demo1 99 multiplication table

Source: Internet
Author: User

After learning the selection cycle, we began to extrapolate, write 3 small demo to try it.

First 99 multiplication table:

/*

* This is a program that prints out the 99 multiplication table Jiujiuchengfabiao

*/

public class jiujiuchengfabiao{

public static void Main (string[] args) {

Loop two 1~9 number multiplied, the second layer of circular printing add space is to let the results separate look good, each loop after the end of the line, so that looks like a multiplication table.

for (int j = 1;j<=9;j++) {

for (int k = 1;k<=j;k++) {

System.out.print (j + "X" + k + "=" + (j*k) + "T");

In order to print out the results of beautiful, aligned, but also in the inner loop of the output statement to modify the

System.out.print (j + "X" + k + "=" + (j*k) <10? ( J*K):(j*k) + "") + "T");

}

System.out.println ();

}

}

}

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.