已阅读5页,还剩3页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
第一章1public class BegintoLearn public static void main(String args) System.out.println(Id like to study Java ! ); 2 public class TraStar public static void main(String args) System.out.println(*);System.out.println(* *);System.out.println(* * *);System.out.println(* * * *);System.out.println(* * * * *); 第二章1public class ProNum public static void main(String args) float p; long q; int m=10,n=5; System.out.println(m=+m+ n=+n); m=m+3;n=n+5; System.out.println(m=+m+ n=+n); p=(float)(m+n)/2; System.out.println(p=+p); q=(m*m*n*n); System.out.println(q=+q); 2 class SphereClass public static void main(String args) int r=3; double v; v=3.14*r*r*r*4/3; System.out.println(V=+v) 第三章1. import java.io.*;public class InNum public static void main(String args) throws IOException int num1,num2; String str; BufferedReader buf; buf=new BufferedReader(new InputStreamReader(System.in); System.out.print(Input first integer:); str=buf.readLine(); num1=Integer.parseInt(str); System.out.print(Input second integer:); str=buf.readLine(); num2=Integer.parseInt(str); System.out.println(The sum is +(num1+num2); 2import java.io.*;public class Grade public static void main(String args) throws IOException int score; char ch; String str; BufferedReader buf; buf=new BufferedReader(new InputStreamReader(System.in); System.out.print(Input the score(0-100):); str=buf.readLine(); score=Integer.parseInt(str); if (score=90) ch=A; else if (score=75) ch=B; else if (score=60) ch=C; else ch=D; System.out.print(The Grade is +ch); 3public class ShuLie public static void main(String args) int a ,q ,n; q=(150-135)/5; a=(135-20*q)/5; for (n=0;n10;n+) System.out.print(a+n*q)+ ); 4public class Pyramid public static void main(String args) int i,j,k; for(i=0;i=4;i+) for ( j=0;j20-i;j+) System.out.print( ); for (k=0;k=2*i;k+) if (k=i) System.out.print( +(2*k+1); else System.out.print( +(2*(2*i-k)+1); System.out.println(); 5import java.io.*;public class PrimeNumber public static void main(String args) throws IOException int n=0; int m; String str; boolean mark=false; BufferedReader buf; buf=new BufferedReader(new InputStreamReader(System.in); System.out.print(Input the m:); str=buf.readLine(); m=Integer.parseInt(str); for(int i=3;i=m;i+=2) for(int j=2;ji;j+) if(i%j=0) mark=true; break; if (!mark) System.out.print( +i); n+; /outputanewline if(n%10=0) /after10numbers System.out.println(); mark=false; System.out.println(); 6import java.io.*;public class Factor12 public static void main(String args) throws IOException int m; String str; BufferedReader buf; buf=new BufferedReader(new InputStreamReader(System.in); System.out.print(Input the m:); str=buf.readLine(); m=Integer.parseInt(str); System.out.print(m+s factors are: ); System.out.println( ); for(int i=1;i=5) m=m/2; d+; System.out.print(d+: ); System.out.println(m); System.out.print(You need +d+ days); 8public class AlmostPi public static void main(String args) int n; long m; double s,t; n=1; m=0; s=0; do t=(double)n/(2*m+1); m+; n=-n; s=s+t; while (4*s-3.14159 0.0000001 | 4*s-3.14159 -0.0000001); System.out.println(m); 9.public class LSRnd public static void main(String args) int mun,n,max1,min1; max1=0; min1=100; for (n=1;nmax1) max1=mun; if (mun=1 & m=12) System.out.println(monthm-1); else System.out.print(Your Input is wrong); 第四章1import java.util.*;public class Personprivate String name; private char sex; private int year,month;public Person( )public Person(String nm,char sx,int y,int m) name=nm; sex=sx; year=y;month=m;public void printPerson( ) Calendar now=Calendar.getInstance();int age=now.get(Calendar.YEAR)-year;System.out.println(Name: +name+,Sex: +sex+, Age: +age);public static void main(String args)Person pe1=new Person(Tom,m,1980,10);pe1.printPerson();2public class Rectangledouble width,length,girth,area; public Rectangle(); public Rectangle(double wd,double le) width=wd;length=le; public void setWidth(double wd) width=wd; public void setLength(double le) length=le; public double getWidth( ) return width; public double getLength( ) return length; public double girth()return 2*(width+length); public double area()return width*length; public void printRectangle()System.out.println(Width=+width+ ,Length=+length); public static void main(String args) Rectangle re1=new Rectangle(10,20); Rectangle re2=new Rectangle(); re2.setWidth(3); re2.setLength(4); re1.printRectangle(); System.out.println(Girth=+re1.girth()+,Area=+re1.area(); re2.printRectangle();System.out.println(Girth=+re2.girth()+,Area=+re2.area();3public class Matrixprivate int mx,m,n; public Matrix(int r,int c) m=r; n=c; mx=new intmn; iniMatrix(); public Matrix() m=3; n=3; mx=new int33;iniMatrix();public void iniMatrix()int i,j; for(i=0;i=m-1;i+) for(j=0;j=n-1;j+) mxij=(int)(Math.random()*100);public void tranMatrix()int i,j,t; int mt=new intmn; for(i=0;i=m-1;i+) for(j=0;j=n-1;j+) mtij=mxij; t=m; m=n; n=t; mx=new intmn; for(i=0;i=m-1;i+) for(j=0;j=n-1;j+) mxij=mtji; public void printMatrix()int i,j;for(i=0;i=m-1;i+) for(j=0;j=n-1;j+) System.out.print( +mxij);System.out.println(); public void addMatrix(Mat
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2025预防医学慢性病流行病学模拟考试试题及解析
- 三年级英语Unit教案湘教版(2025-2026学年)
- 大班疫情主题教案(2025-2026学年)
- 全文解读咬定目标脚踏实地埋头苦干久久为功为黄河永远造福中华民族而不懈奋斗解读教案
- 版机械制图导教案
- 2025智慧医疗影像诊断技术应用现状辅助诊疗分析及医学影像数据管理研究报告
- 人教版九年级物理《电磁波》新授课教案
- 长春师范高等专科学校《工程技术基础》2025-2026学年第一学期期末试卷
- 跨境冷链配送服务条款
- 企业IT基础设施服务协议
- 1绪论-固体废物处理与处置课件
- 转型培训师金牌讲师的12堂必修课读书笔记
- 2024年社区警务规范考试题库
- 废弃矿洞封堵合同范例
- 第五单元简易方程 提升练习题(单元测试)-2024-2025学年五年级上册数学人教版
- (新教科版)科学五年级上册全册教学反思
- 给水厂课程设计
- 版式设计智慧树知到期末考试答案章节答案2024年广州市海珠工艺美术职业学校
- 财政投资评审咨询服务预算和结算评审项目投标方案(技术标)
- 第12课19世纪下半期资本主义的扩展课件-2023-2024学年中职高二全学期高教版(2023)世界历史全一册
- 2022年版初中物理课程标准解读-课件
评论
0/150
提交评论