1  注意不同类型转换

 import java.util.Scanner;

 public class Ch02 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
double f = sc.nextDouble();
double t = (5.0/9)*(f-32); // 注意 (5/9) 结果为 整形 要写成 (5.0/9)
System.out.println(t)
}

2  本题水题,会圆柱体的基本公式即可

 import java.util.Scanner;

 public class Ch02 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.println("请输入圆柱体半径和高:");
double r = sc.nextDouble();
double h = sc.nextDouble();
double v = Math.PI * r * r * h; //圆周率方法 Math.PI
System.out.println(v);
}

3  本题水题,知道公式即可

 import java.util.Scanner;

 public class Ch02 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.println("请输入体重和身高:");
double g = sc.nextDouble();
double h = sc.nextDouble();
double BMI = g / (h * h);
System.out.println(BMI);
}

4  使用 循环 每次对 个位 取数相加 取数后 除以10 使前一位 变为 个位 继续 判断小于等于0时停止

 import java.util.Scanner;

 public class Ch02 {
public static void main(String[] args) {
int sum = 0;
Scanner sc = new Scanner(System.in);
int num1 = sc.nextInt();
while (num1 > 0) // 与 0 比较 判断 是否 需要 取数
{
sum += (num1%10); // 通过取余 获得个位数字
num1 /= 10; // 每次取余后 除以10
}
System.out.println(sum);
}

5  注意 System.currentTimeMillis()方法 返回 long 形 需要转换为 int 形

 public class Ch02 {
public static void main(String[] args) {
// 通过 System.currentTimeMillis() 方法 获得 从1970年1月1日 00:00:00 到现在的 毫秒数
// 28800000 是 格林时间 与 我们 时区 的 时间差值
// 对 86400000 取余 是 把 满一天的时间都去掉 获取多出来的不足一天的时间
int t = (int)((System.currentTimeMillis()+28800000)%86400000);
int hour = t/3600000; // 除 3600000 获取满小时的个数 即 求小时 为几点
int mine = t%3600000/60000; // 计算 不足一小时 的时间 里 有多少分钟
int s = t%3600000%60000/1000; // 计算不足一分钟的时间里 有多少秒 不要忘记 除以 1000 (因为 单位 为 毫秒)
System.out.println("当前时间: "+hour+":"+mine+":"+s+" GMT");
}

6  a 不能为 0  b2 - 4 * a * c  不能为 0

 import java.util.Scanner;

 public class Ch02 {
public static void main(String[] args) {
double sum,a,b,c,t;
Scanner sc = new Scanner(System.in);
while (true) {
a = sc.nextDouble();
b = sc.nextDouble();
c = sc.nextDouble();
t = b*b-4*a*c;
if (a == 0) {
System.out.println("a 不能为 0,请重新测试 ^_^");
} else if (t < 0) {
System.out.println("b*b-4*a*c不能为0,请重新测试");
}
else
{
break;
}
}
sum = ((-b+Math.sqrt(t)/(2*a))); //( 2*a ) 注意加括号
System.out.println(sum);

7  注意计算公式先后顺序  多使用小括号

 import java.util.Scanner;

 public class Ch02 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
double yrate = sc.nextDouble();
double amount = sc.nextDouble();
double year = sc.nextDouble();
double month = (amount * (yrate/12))/(1-(1/Math.pow(1+yrate/12,year*12)));
double sumamount = month*12*year;
System.out.println("月支付金额:"+month+"\n总偿还金额:"+sumamount);
}

注意:

本单元感谢

一曲、長歌  的得力配合

最新文章

  1. android studio...混淆打包全揭秘
  2. PMP--论文部分
  3. JAVA基础知识之JVM-——URLClassLoader
  4. 超强vim配置
  5. JavaScript算法题之–随机数的生成
  6. C# 操作XML 如果不存在创建 存在直接追加
  7. 打开一个已经写好的Android studio工程的方法
  8. WebService开发步骤
  9. Java生成缩略图之Thumbnailator
  10. java程序测试之字节流
  11. HTML &lt;form&gt; 标签的 method 属性(20161028)
  12. OSS.Core基于Dapper封装(表达式解析+Emit)仓储层的构思及实现
  13. TDD 之 Dojo coding
  14. Python内置函数(35)——next
  15. (java基础)Java输入输出流及文件相关
  16. freemarker使用
  17. 串的模式匹配算法 ------ KMP算法
  18. 第六篇:Jmeter Ftp服务器的连接
  19. 函数中返回char *类型
  20. Reverse string using recursion

热门文章

  1. 京东商城跨域设置Cookie实现SSO单点登陆过程
  2. RabbitMQ学习之:(八)Topic Exchange (转贴+我的评论)
  3. openstack核心组件--horizon web管理界面(5)
  4. Webupload+PHP上传大文件
  5. Elasticsearch 空值过滤
  6. Redis 集群部署
  7. 35 个最好用 Vue 开源库
  8. 20190905 - Uncaught SyntaxError: Unexpected token &lt; 的解决
  9. PHP SQL注入
  10. 微信小程序实现navbar导航栏