标签:public java 结果 运算符 char pack 应用 ble 整型
1、已知a,b均是整型变量,写出将a,b两个变量中的值互换的程序。(知识点:变量和 运算符综合应用)
package finish; public class chap1 { public static void main(String[] args) { int a=5; int b=8; int c; c=a; a=b; b=c; System.out.println("互换后的a是+"a); System.out.println("互换后的b是"+b); } }
public class chap1 { public static void main(String[] args) { int a =562; int b, c, d, e, sum; e = a / 1000; b = a / 100 % 10; c = a / 10 % 10; d = a % 10; sum = b +c +d +e; System.out.println("结果为" + sum); } }
3、华氏度50转成摄氏度是多少???(华氏温度和摄氏温度互相转换,从华氏度变成
摄氏度你只要减去32,乘以5再除以9就行了,将
摄氏度转成华氏度,直接乘以9,除以5,再加上
32即行)
public class chap1 { public static void main(String[] args) { double a=50; double s; s = (a-32)*5/9; System.out.println("转成摄氏度的值是:"+s); } }
4、给定一个任意的大写字母A~Z,转换为小写字母。 (知识点:变量和运算符)
public class chap1 { public static void main(String[] args) { char b = ‘B‘; System.out.println((char)(b + 32)); } }
标签:public java 结果 运算符 char pack 应用 ble 整型
原文地址:https://www.cnblogs.com/lutiantian/p/12523473.html