1、3-1 import java.util.*; public class XIN31 public static void main(String args) double sum; Scanner reader=new Scanner(System.in); System.out.println(“请输入一个值 :“); double x=reader.nextDouble(); if(x=0) sum=2*x-1; System.out.println(“y=“+sum); else sum=3*x-1; System.out.println(“y=“+sum); 3-2 public c
2、lass XIN32 public static void main(String args) int sum=0,j; int i=1; while(i=1000) j=i%(7*3); if(j=0) sum=sum+i; i+; else i+; System.out.println(“数 值 =“+sum); 3-3 import java.util.*; public class XIN33 public static void main(String args) int i = 0, a = 8, sum = 8; for (i = 1; i = 9; i+) a = a * 10
3、 + 8; sum = sum + a; System.out.println(“数值 =“ + sum); 3-4 public class XIN34 public static void main(String args) int sign=-1; double deno=1.0,term,sum=0.0; while(deno=19999) sign=-sign; term=sign/deno; sum=term+sum; deno=deno+2; System.out.println(“结果为 =“+sum); 3-5 import java.util.*; public class
4、 XIN35 public static void main(String args) int i = 0, sum = 0, sum1 = 0, sum2 = 0; int j = 0, a, b, c; for (i = 0; i = 199; i+) a = i * (i - 1); a = a * (i + 1); sum1 = sum + a; for (j = 0; j = 99; j+) b = j * (j - 1); b = b * (j + 1); sum2 = sum + b; c = sum1 - sum2; System.out.println(“结果为 “ + c);