Programming exercises in the 1th chapter of Java language programming

Source: Internet
Author: User

1.1

 Public class Test {    publicstaticvoid  main (string[] args) {        System.out.println ( "Welcome to Java");        System.out.println ("Welcome to Computer");        SYSTEM.OUT.PRINTLN ("Programming is Fun");}    }

1.2

 Public class Test {    publicstaticvoid  main (string[] args) {        for ( int i = 0; I < 5; i++) {            System.out.println ("Welcome to Java");     }}}

1.3

 Public class Test {    publicstaticvoid  main (string[] args) {        System.out.println ( "   J    a    v     v    a");        System.out.println ("   J   a a    v   v    a");        System.out.println ("J  J  AAAAA    v v    AAAAA");        System.out.println ("JJ  a     a    V    a     ");    }}

1.4

 Public class Test {    publicstaticvoid  main (string[] args) {        System.out.println ( "A     a^2   a^3");        System.out.println ("1     1     1");        System.out.println ("2     4     8");        System.out.println ("3     9     ");        System.out.println ("4    ");}    }

1.5

 Public class Test {    publicstaticvoid  main (string[] args) {        double s = (9.5*4.5-2.5*3)/(45.5-3.5);        System.out.println (s);   // 0.8392857142857143     }}

1.6

 Public class Test {    publicstaticvoid  main (string[] args) {        int s=0 ;          for (int i=0; i<10; + +i) {            s+ =i;        }        System.out.println (s);   //  $     }}

1.7

 Public classTest { Public Static voidMain (string[] args) {DoublePI = 0; DoubleT; intM=1;  for(intI=1; i<12121358; i++) {T=1.0/(2*i-1); T*=m; Pi+=T; M*=-1; } Pi*=4; System.out.println (PI); //3.1415927360890374    }}

Programming exercises in the 1th chapter of Java language programming

Related Article

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.