全文预览已结束
下载本文档
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
4.11题public class s11 /* * param args */public static void main(String args) / TODO Auto-generated method stub int count=0;for(int i=100;i=200;i+) if(i%5=0|i%6=0)&(i%30!=0) count+; System.out.print(i+ ); if(count%10=0) System.out.println(); 结果:100 102 105 108 110 114 115 125 126 130 132 135 138 140 144 145 155 156 160 162 165 168 170 174 175 185 186 190 192 195 198 2004.18题apublic class S411 /* * param args */public static void main(String args) / TODO Auto-generated method stub for(int i=0;i6;i+) for(int j=0;j=i;) System.out.print(+j); System.out.println(); 结果:11212312341234512345618题cpublic class c18 /* * param args */public static void main(String args) / TODO Auto-generated method stubint i,j;for(i=0;ii;j-)System.out.print( );for(j=i+1;j0;j-)System.out.print(j); System.out.println(); 结果:1 21 321 4321 54321654321第五章编程练习作业5.2import javax.swing.*;public class s52 /* * param args */public static void main(String args) / TODO Auto-generated method stublong m=Integer.parseInt(JOptionPane.showInputDialog(null,输入一个整数:);System.out.print(sumDigits(m);public static long sumDigits(long n)long sum=0;long i=0;while(n!=0)i=n%10;n=n/10;sum=sum+i;return sum;5.4import javax.swing.JOptionPane;public class s54 /* * param args */public static void main(String args) / TODO Auto-generated method stubint m=Integer.parseInt(JOptionPane.showInputDialog(null,输入一个整数:);reverse(m);public static void reverse(int n)long i=0;while(n!=0)i=n%10;n=n/10;System.out.print(i);5.4import javax.swing.JOptionPane;public class s544 /* * param args */public static void main(String args) / TODO Auto-generated method stublong m=Integer.parseInt(JOptionPane.showInputDialog(null,输入一个整数:);System.out.print(sumDigits(m);public static long sumDigits(long n)long sum=0;long i=0;while(n!=0)i=n%10;n=n/10;sum=sum*10+i;return sum;6.5import javax.swing.JOptionPane;public class 6.5public static void main(String args)int num = new int10;boolean zero = false;int j = 0;for(int i = 0;i 10 ;i+)int number = Integer.parseInt(JOptionPane.showInputDialog(Enter a number:);if(number = 0)zero = true;if(number != 0)for(j = 0;j = i)numi = number;if(zero)System.out.println(0);for(int i = 0;i num.length;i+)if(numi != 0)System.out.println(numi);6.7public class Exercise6_7 public static void main(String args) / TODO Auto-generated method stubint counts = new int10;int num = 0;for(int i = 0;i 100;i+)num = (int)(Math.random()*10);countsnum+;System.out.println(统计结果为:);System.out.print(随机数: );for(int i = 0;i counts.length ; i+)System.out.print( + i);System.out.print(n出现次数:);for(int i = 0;i counts.length ; i+)if(countsi 10)System.out.print( + countsi);else System.out.print( + countsi);7.1public class Rectangle double width=1;double height=1;String color=white;public Rectangle()public Rectangle(double width,double height,String color)this.width=width;this.height=height;this.color=color;public void setwidth(double width)this.width=width;public void setcolor(String color)this.color=color;public double getwidth()return width;public double getheight()return height;public double getArea()return width*height;public double getAPerimeter()return 2*(width+height); class Testpublic static void main(String args)Rectangle r1=new Rectangle(4,40,red);Rectangle r2=new Rectangle(3.5,35.9,red);r1.getArea();r1.getAPerimeter();r2.getArea();r2.getAPerimeter();Sy
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 员工绩效考核管理系统模板
- 四年级语文综合学习教学设计
- 餐饮行业食品安全管理操作流程
- 广告公司客户需求调研方案
- 职业技能标准制定及应用分析
- 产品设计与开发工具库
- 健康医疗产业服务质量提升承诺书范文6篇
- 动物与人类的友谊话题作文12篇范文
- 教师心理健康支持与干预计划
- 2025医疗健康远程医疗产业市场深度分析及行业前景与投资规划研究报告
- 2024年新人教版七年级上册数学教学课件 第二章 有理数的运算 综合与实践 进位制的认识与探究
- 设备管理平台架构设计-深度研究
- 电磁技术在医疗诊断中的应用与安全性分析
- 剧毒易制爆培训课件
- 村委会维修合同范例
- 排泄护理基础护理学
- 成功品牌的共性与启示计划
- 中医基础理论之八纲辨证课件
- 殡葬礼仪服务整体服务方案
- 铁电材料的频率依赖性研究
- SMT失效模式分析PFMEA
评论
0/150
提交评论