3.19 第二次作业
1 二. 2 package hm; 3 /* 4 * 计算1--1000的个个位数相加 5 */ 6 import java.util.Scanner; 7 8 public class Practice01 { 9 10 public static void main(String[] args) { 11 Scanner r= new Scanner(System.in); 12 System.out.println("输入一个四位数"); 13 int a = r.nextInt(); 14 int g,s,b,q,sum; 15 q= a/1000; 16 b = a/100%10; 17 s= a/10%10; 18 g= a%10; 19 sum = g+s+b+q; 20 System.out.println(sum); 21 22 三.package hm; 23 24 import java.util.Scanner; 25 26 public class Practice02 { 27 28 public static void main(String[] args) { 29 Scanner r = new Scanner(System.in); 30 System.out.println("输入华氏温度"); 31 double H = r.nextDouble(); 32 double C = (H-32)*5/9; 33 System.out.println("摄氏温度:"+C); 34 35 } 36 37 } 38 39 四. 40 package hm; 41 /* 42 * 字符转换大小写 43 */ 44 public class Practice03 { 45 46 public static void main(String[] args) { 47 String a = "i love you"; 48 String A = a.toUpperCase(); 49 System.out.println("原字符串:"+a); 50 System.out.println("大写字符串:"+A); 51 } 52 53 }