第二次上机作业
package week2; public class Week1 { /** * @param args */ public static void main(String[] args) { // TODO Auto-generated method stub double r = 4.5; double s; s = r * r * 3.14; System.out.println("圆的面积为" + s); } }
package week2; public class Week2 { /** * @param args */ public static void main(String[] args) { // TODO Auto-generated method stub double hua = 50; double she; she = (hua - 32) * 5 / 9; System.out.println("从华氏度变成摄氏度为" + she); double shes = 60; double huas; huas = shes * 9 / 5 + 32; System.out.println("从摄氏度变成华氏度为" + huas); } }
package week2; public class Week4 { /** * @param args */ public static void main(String[] args) { // TODO Auto-generated method stub int a = 1; int b = 2; int c; c = a; a = b; b = c; System.out.println(a); System.out.println(b); } }
package week2; public class Week5 { /** * @param args */ public static void main(String[] args) { // TODO Auto-generated method stub int a = 12345; int b; b = a / 100 * 100; System.out.println(b); } }
package second; import java.util.*; public class Second3 { /** * @param args */ public static void main(String[] args) { // TODO Auto-generated method stub System.out.println("请输入一个0~1000的整数"); Scanner sc = new Scanner(System.in); int a = sc.nextInt(); int b,c,d,sum; b=a%10; c=a%100/10; d=a/100; sum=b+c+d; System.out.println("结果为"+sum); } }
package week2; public class Week6 { /** * @param args */ public static void main(String[] args) { // TODO Auto-generated method stub char c = 'a'; char e = 'A'; System.out.println((char) (c - 32)); System.out.println((char) (e + 32)); } }