Home > Back-end >  Java programming problem
Java programming problem

Time:01-07

Programming 1 2 will write trouble you!

CodePudding user response:

This is the test you,,,
Another post is your classmate? https://bbs.csdn.net/topics/398773688

CodePudding user response:

Problem a:
Public class Demo01 {
Public static void main (String [] args) {
//TODO Auto - generated method stub
Circle c1=new Circle (100);
Circle the c2=new Circle (200);
System. The out. Println (" c1 the area of a circle: "+ c1. Area () +" circumference: "+ c1. Generating ());
System. The out. Println (" c2 the area of a circle: "+ c2. Area () +" circumference: "+ c2. Generating ());
}
}
The class Circle {
Public int the radius;
Final double PI=3.14;
Circle radius, (int) {
Enclosing the radius=radius;
}
Public double area () {
Return the radius radius, * * PI;
}
Public double generating () {
Return the radius * 2 * PI;
}
}
Problem two:
Public class X4_3_2 {
Public static void main (String args []) {
Student s1=new Student (1, "zhang", "male", 18);
Student s2=new Student (2, "bill", "female", 20).
S1. ShowNo ();
S1. ShowName ();
S1. ShowSex ();
S1. ShowAge ();
System. The out. Println ("===========");
S2. ShowNo ();
S2. ShowName ();
S2. ShowSex ();
S2. ShowAge ();
System. The out. Println ("===========");
S1. ModifyAge (25);
System. The out. Println (" the revised result: ");
S1. ShowAge ();
}
}
The class Student {
Int s_No;
String s_Name;
String s_Sex;
Int s_Age;
Student (int s_No, String s_Name, String s_Sex, int s_Age) {
Enclosing s_No=s_No;
Enclosing s_Name=s_Name;
Enclosing s_Sex=s_Sex;
Enclosing s_Age=s_Age;
}
Public void showNo () {
System. Out. Println (" student id: "+ s_No);
}
Public void showName () {
System. The out. Println (" name: "+ s_Name);
}
Public void showSex () {
System. The out. Println (" gender: "+ s_Sex);
}
Public void showAge () {
System. The out. Println (" age: "+ s_Age);
}
Public void modifyAge (int s_Age) {
Enclosing s_Age=s_Age;
}
}

CodePudding user response:

refer to the second floor qq_42672151 response:
problem a:
Public class Demo01 {
Public static void main (String [] args) {
//TODO Auto - generated method stub
Circle c1=new Circle (100);
Circle the c2=new Circle (200);
System. The out. Println (" c1 the area of a circle: "+ c1. Area () +" circumference: "+ c1. Generating ());
System. The out. Println (" c2 the area of a circle: "+ c2. Area () +" circumference: "+ c2. Generating ());
}
}
The class Circle {
Public int the radius;
Final double PI=3.14;
Circle radius, (int) {
Enclosing the radius=radius;
}
Public double area () {
Return the radius radius, * * PI;
}
Public double generating () {
Return the radius * 2 * PI;
}
}
Problem two:
Public class X4_3_2 {
Public static void main (String args []) {
Student s1=new Student (1, "zhang", "male", 18);
Student s2=new Student (2, "bill", "female", 20).
S1. ShowNo ();
S1. ShowName ();
S1. ShowSex ();
S1. ShowAge ();
System. The out. Println ("===========");
S2. ShowNo ();
S2. ShowName ();
S2. ShowSex ();
S2. ShowAge ();
System. The out. Println ("===========");
S1. ModifyAge (25);
System. The out. Println (" the revised result: ");
S1. ShowAge ();
}
}
The class Student {
Int s_No;
String s_Name;
String s_Sex;
Int s_Age;
Student (int s_No, String s_Name, String s_Sex, int s_Age) {
Enclosing s_No=s_No;
Enclosing s_Name=s_Name;
Enclosing s_Sex=s_Sex;
Enclosing s_Age=s_Age;
}
Public void showNo () {
System. Out. Println (" student id: "+ s_No);
}
Public void showName () {
System. The out. Println (" name: "+ s_Name);
}
Public void showSex () {
System. The out. Println (" gender: "+ s_Sex);
}
Public void showAge () {
System. The out. Println (" age: "+ s_Age);
}
Public void modifyAge (int s_Age) {
Enclosing s_Age=s_Age;
}
}
thank you!

CodePudding user response:

reference 1st floor zhuangqingch response:
this is the test you,,,
Another post is your classmate? https://bbs.csdn.net/topics/398773688
the final assignment

CodePudding user response:

refer to the second floor qq_42672151 response:
problem a:
Public class Demo01 {
Public static void main (String [] args) {
//TODO Auto - generated method stub
Circle c1=new Circle (100);
Circle the c2=new Circle (200);
System. The out. Println (" c1 the area of a circle: "+ c1. Area () +" circumference: "+ c1. Generating ());
System. The out. Println (" c2 the area of a circle: "+ c2. Area () +" circumference: "+ c2. Generating ());
}
}
The class Circle {
Public int the radius;
Final double PI=3.14;
Circle radius, (int) {
Enclosing the radius=radius;
}
Public double area () {
Return the radius radius, * * PI;
}
Public double generating () {
Return the radius * 2 * PI;
}
}
Problem two:
Public class X4_3_2 {
nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull
  • Related