Java class and object 5, Java Class Object 5

Source: Internet
Author: User

Java class and object 5, Java Class Object 5

Write a Java application, which includes two classes: Print class and main Class E. The output () function of a method in the Print class is to output 100 ~ All the daffodils between 999 (the cubes of each number are equal to the three numbers themselves, for example:

371 = 33 + 73 + 13 .) Test the Print class in the main method of main Class E.

 

1 class sXianHuaShu {2 void outPut () {3 for (int I = 100; I <= 999; I ++) {4 int gw = I % 10; 5 int sw = I/10% 10; 6 int bw = I/100; 7 if (I = gw * gw + sw * sw + bw * bw) {8 System. out. println (I); 9} 10} 11} 12 13 public static void main (String [] args) {14 sXianHuaShu shu = new sXianHuaShu (); 15 shu. outPut (); 16 17}

Result:

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.