class person1 {
String name;
String sex;
int age;
String ID;//身份证号码
void getperson(String name,String sex,int age,String ID)
{
System.out.println("名字为:"+name+";性别为:"+";年龄为:"+age+";身份证为:"+ID);
}
}
public class person{
public static void main(String[] args) {
person1 cc=new person1();
cc.getperson("张三","男" ,18 ,"43010101010101010" );
cc.getperson("李四","女" ,18 ,"123456789009876543" );
}
}
第二题
package day33;
class phone1 {
String name;
String nx;
void getphone1(String name,String nx)
{
System.out.println("手机的品牌为:"+name+"手机的类型为:"+nx);
}
}
public class phone{
public static void main(String[] args) {
phone1 cc=new phone1();
cc.getphone1("华为","荣耀3c");
cc.getphone1("联想","A3600D");
cc.getphone1("小米","note");
}
}
第三题
package day33;
class book1 {
String name;
String num;//书籍号码
String name1;//主编
String name3;//出版社
String time;//出版时间
int num1;//页数
double money;
void getbook(String name,String num,String name1,String name3,String time,int num1,double money) {
System.out.println("书的名字:"+name+";书籍号码:"+num+";主编:"+name1+";书的出版社:"+name3+";出版时间:"+time+";页数:"+num1+";价格:"+money);
}
}
public class book{
public static void main(String[] args) {
book1 cc=new book1();
cc.getbook("某一本书","111111","某某某","某一个出版社","12 3",100,100.0);
}
}
第四题
package day33;
class yzt1 {
final double PI= 3.14;
int a;//圆柱体的半径
int b;//圆柱体的高
double c,d;//分别代表圆柱体的底面积和体积
void dyj( int a)
{
c=PIaa;
System.out.println("圆柱体的底面积为:"+c);
}
void tj(int b) {
d=c*b;
System.out.println("圆柱体的体积为:"+d);
}
}
public class yzt{
public static void main(String[] args) {
yzt1 cc=new yzt1();
cc.dyj(10);
cc.tj(10);
转载于:https://www.cnblogs.com/jjlk/p/11134896.html