第二次Java作业2
---恢复内容开始---
package iop; import java.util.Scanner; public class person { private String name; private String sex; private int idnumber; private int age; public static void main(String[]args) { String name; String sex ; double age; double idnumber; // person s1=new person(); s1.name="李四"; s1.sex="female"; s1.age=18; s1.idnumber=123456734; person s2=new person(); s2.name="张三"; s2.sex="male"; s2.age=18; s2.idnumber=431010101; System.out.println("名字"+s1.name+"性别"+s1.sex+"年龄"+s1.age+"身份证号码"+s1.idnumber); System.out.println("名字"+s2.name+"性别"+s2.sex+"年龄"+s2.age+"身份证号码"+s2.idnumber); } }
package gvfg; import java.util.*; public class Phone1 { public Phone1() { Scanner q=new Scanner(System.in); String q1=q.nextLine(); System.out.println("手机品牌:"+q1); Scanner w=new Scanner(System.in); String w1=w.nextLine(); System.out.println("手机型号:"+w1); } public static void main(String[] args) { new Phone1(); } }
package gvfg; public class PhoneTest { private String label1; private String type1; public static void main(String[] args) { //String label1; PhoneTest q1=new PhoneTest() ; q1.label1="华为"; q1.type1="荣耀3c"; PhoneTest q2=new PhoneTest(); q2.label1="小米"; q2.type1="note"; PhoneTest q3=new PhoneTest(); q3.label1="联想"; q3.type1="A3600D"; System.out.println("手机品牌: "+q1.label1+" 手机型号: "+q1.type1); System.out.println("手机品牌: "+q2.label1+" 手机型号:"+q2.type1); System.out.println("手机品牌: "+q3.label1+" 手机型号:"+q3.type1); } }
package asd; import java.util.*; public class Book { public static void main(String[] args) { System.out.println("请输入书名:"); Scanner q=new Scanner(System.in); String q1=q.nextLine(); System.out.println("书名:"+q1); System.out.println("请输入书号:"); Scanner w=new Scanner(System.in); int w1=w.nextInt(); System.out.println("书号:"+w1); System.out.println("请输入主编姓名:"); Scanner e=new Scanner(System.in); String e1=e.nextLine(); System.out.println("主编:"+e1); System.out.println("请输入出版社:"); Scanner r=new Scanner(System.in); String r1=r.nextLine(); System.out.println("出版社:"+r1); System.out.println("请输入出版时间:"); Scanner t=new Scanner(System.in); String t1=t.nextLine(); System.out.println("出版时间:"+t1); System.out.println("请输入页数:"); Scanner y=new Scanner(System.in); int y1=y.nextInt(); System.out.println("页数"+y1); System.out.println("请输入价格:"); Scanner u=new Scanner(System.in); int u1=u.nextInt(); System.out.println("价格"+u1); } }
package gvfg; public class BookTest { private String bookname; private int booknumber; private String auther; private String publisher; private int time; private int page; private int price; public static void main(String[] args) { BookTest q1=new BookTest(); q1.bookname="斗破苍穹"; q1.booknumber=213214343; q1.auther="天蚕土豆"; q1.publisher="起点中文网"; q1.time=2007; q1.page=500; q1.price=50; BookTest q2=new BookTest(); q2.bookname="斗罗大陆"; q2.booknumber=21332334; q2.auther="唐家三少"; q2.publisher="起点中文网"; q2.time=2009; q2.page=500; q2.price=50; System.out.println("书名: "+q1.bookname+"出版社:"+q1.publisher+" 书号: "+q1.booknumber+" 作者: "+q1.auther+" 出版时间 :"+q1.time+" 页数 :"+q1.page+" 价格: "+q1.price); System.out.println("书名: "+q2.bookname+"出版社:"+q2.publisher+" 书号 :"+q2.booknumber+" 作者 :"+q2.auther+" 出版时间 :"+q2.time+" 页数: "+q2.page+" 价格: "+q2.price); } }
package asd; public class Cylinder { public final static float PI= 3.14f; public static void main(String[] args) { int r=5,h=6; float area; float bulk; area=r*r*PI; bulk=area*h; System.out.println("底面积为:"+area+" "+"体积为"+bulk); } }
package asd; import java.util.*; public class CylinderTest { public final static float PI= 3.14f; public static void main(String[] args) { System.out.println("请输入半径和高!"); float area;float bulk; Scanner q=new Scanner(System.in); int q1=q.nextInt(); Scanner w=new Scanner(System.in); int w1=w.nextInt(); area=q1*q1*PI; bulk=area*w1; System.out.println("面积为"+area); System.out.println("体积为"+bulk); } }
---恢复内容结束---