java test1
来源:互联网 发布:身份证nfc读取 软件 编辑:程序博客网 时间:2024/06/07 07:49
练习1:
使用公式C=(5/9)(F-32)打印下列华氏温度与摄氏温度对照表。
0 -17
20 -6
40 4
60 15
80 26
100 37
120 48
140 60
160 71
180 82
200 93
220 104
240 115
260 126
280 137
300 148
(1).
public class wendu{public static void main(String[] args) {int f=0;double c;for(f=0;f<=300;f=f+20){c=(5.0/9)*(f-32);System.out.println(f+""+c);}}}
(2).
public class wendu{public static void main(String[] args) {int f=0;double c;for(f=0;f<=300;f=f+20){c=(5.0/9)*(f-32);System.out.print(f+"");System.out.printf("%.1f",c);System.out.print("\n");}}
}
(3)
public class wendu{public static void main(String[] args) {int f=0;double c;for(f=300;f>=0;f=f-20){c=(5.0/9)*(f-32);System.out.print(f+"");System.out.printf("%.1f",c);System.out.print("\n");}}
}
练习2:
打印出所有的"水仙花数",所谓"水仙花数"是指一个三位数,其各位数字立方和等于该数本身。例如:153 是一个"水仙花数",因为153=1的三次方+5的三次方+3的三次方。public class shuixianhua {public static void main(String args[]) {int num = 100;int i,j,k;for(num= 100;num<1000;num++){i = num / 1 % 10;j = num / 10 % 10; k = num / 100 % 10;if(num ==i*i*i+j*j*j+k*k*k ){System.out.println(num); } } }}
练习3:
求1+2!+3!+...+20!的和
public class jiec{public static void main(String args[]){int i=1;double sum=1;double num=1;for(i=1;i<=20;i++){num=num*i;sum=sum+num; }System.out.println(sum); }}
阅读全文
1 0
- java test1
- test1
- test1
- test1
- test1
- test1
- test1
- TEST1
- test1
- test1
- TEST1
- Test1
- test1
- Test1
- Test1
- Test1
- test1
- test1
- The DispatcherServlet configuration needs to include a HandlerAdapter that supports this handler
- <剑指offer>深度探索(一)实现string 类以及单例模式的具体实现
- SQL基本语句
- 彻底解决 Eclipse出现the user operation is waiting的问题
- 第七章 复用类
- java test1
- 第5章 排序 —— 5.1 基数排序
- CCF 201312-2 ISBN号码
- 在Linux中使用VS Code编译调试C++项目
- 游戏联动与精准研发的趋势
- centos 7搭建简单的vpn服务器
- Android Studio快速导入Project的正确方法
- centos7搭建pureftpd服务器
- 富文本编辑器UEditor的配置使用方法