PackageCom.lianxi; Public classStudent {//write Java applications. First, define the class--student that describe the student, including the study number (int),//attributes such as name (String), age (int), two methods: Student (int stuno,string name,int ages)//used to initialize the object, output () is used for outputting student information. Second, define a main class--//TestClass, create multiple objects of the student class in the main method of the Master class, using these objects to measure//try to student the function of the class. intStuno,age; String name; Student (intStuno,string name,intAge ) { This. stuno=Stuno; This. name=name; This. age=Age ; } voidOutPut () {System.out.println ("School Number:" +stuno+ "Name:" +name+ "Age:" +Age ); } Public Static voidMain (string[] args) {Student S1=NewStudent (13254, "Zhang San", 21); S1.output (); }}
Write a Java application that consists of 2 classes: The Print class and the main class E. Print
There is a method in the class output () function that outputs 100 ~ 999 of all daffodils (the number of
The cubic and equals this three-digit number itself, such as: 371 = 33 + 73 + 13. ) in main class E, in the Main method
Test the class print.
Public classPrint {voidoutput () {System.out.println ("The number of daffodils is"); for(intx=1;x<10&&x>=1;x++) { for(inty=0;y<10&&x>-1;y++) { for(intz=0;z<10&&x>-1;z++) { if(x*x*x+y*y*y+z*z*z==x*100+y*10+z) {System.out.println (x+ "" +y+ "" +z); } } } } } Public Static voidMain (string[] args) {//TODO Auto-generated method stubsPrint p1=NewPrint (); P1.output (); }}
Java Object-oriented exercises 4