1.从键盘输入两个整数,两个数之间用空格隔开,以回车键结束:
  123 345
  123+345 = 468
2.从键盘输入两个整数,两个数之间用空格隔开,以回车键结束:
  12 34
  请从键盘上输入运算符号,以回车键结束。
  *
  12* 34 = 408
3.要求:输入某个工资数,计算并输出应缴纳税额4.编写程序求解一元二次方程。本人是做.net的,没java环境,需要能实现的编译后的程序,哪位高手改实现了,立刻结贴给分。跪谢

解决方案 »

  1.   


    public static void main(String[] args) {        Scanner sc = new Scanner(System.in);
            System.out.println(sc.nextInt() + sc.nextInt());
            //System.out.println(sc.nextInt() * sc.nextInt());    }2
    public static void main(String[] args) {        Scanner sc = new Scanner(System.in);
            // System.out.println(sc.nextInt() + sc.nextInt());
            System.out.println(sc.nextInt() * sc.nextInt());    }
      

  2.   

    4
     Scanner sc = new Scanner(System.in);
            // 求解x*x = i;
            int i = sc.nextInt();
            double x = Math.sqrt(i);
            System.out.println(x);    }
      

  3.   

    package test;import java.util.Scanner;public class Scan {
    public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String str = sc.nextLine();
    String[] arr = str.split(" ");
    int account = 0;
    for(int i=0;i<arr.length;i++){
    account += Integer.parseInt(arr[i]);
    }
    System.out.println(account);
    }
    }
    第一题。
      

  4.   

    package test;import java.util.Scanner;public class Scan {
    public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    System.out.println("输入数字:");
    String str = sc.nextLine();
    System.out.println("输入运算符:");
    String[] obj = str.split(" ");
    String arr = sc.nextLine();
    int account = 0;
    if("*".equals(arr)){
    account = Integer.parseInt(obj[0])*Integer.parseInt(obj[1]);
    }else if("/".equals(arr)){
    account = Integer.parseInt(obj[0])/Integer.parseInt(obj[1]);
    }else if("+".equals(arr)){
    account = Integer.parseInt(obj[0])+Integer.parseInt(obj[1]);
    }else if("-".equals(arr)){
    account = Integer.parseInt(obj[0])-Integer.parseInt(obj[1]);
    }
    System.out.println(account);
    }
    }第二题。
      

  5.   

    简单的都被人做完了,来晚了,还好还有第三题。public class GeShui { public static void main(String[] args) { Scanner sc = new Scanner(System.in);
    int a = 0;
    int i = sc.nextInt();
    if(i-3500<=0){
    a = 0;
    }else if (i - 3500 <= 1500) {
    a = 1;
    } else if (i - 3500 <= 4500) {
    a = 2;
    } else if (i - 3500 <= 9000) {
    a = 3;
    } else if (i - 3500 <= 35000) {
    a = 4;
    } else if (i - 3500 <= 55000) {
    a = 5;
    } else if (i - 3500 <= 80000) {
    a = 6;
    } else {
    a = 7;
    }
    switch (a) { case 1:
    System.out.println((i - 3500) * 0.03);
    break;
    case 2:
    System.out.println((i - 3500) * 0.10 - 105);
    break;
    case 3:
    System.out.println((i - 3500) * 0.20 - 555);
    break;
    case 4:
    System.out.println((i - 3500) * 0.25 - 1005);
    break;
    case 5:
    System.out.println((i - 3500) * 0.30 - 2755);
    break;
    case 6:
    System.out.println((i - 3500) * 0.35 - 5505);
    break;
    case 7:
    System.out.println((i - 3500) * 0.45 - 13505);
    break;
    default:
    System.out.println("0");
    } }
    }
      

  6.   

    package test;import java.util.Scanner;public class Scan {
    public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    System.out.println("输入工资:");
    String str = sc.nextLine();
    int money = Integer.parseInt(str);
    int b = money - 3500;
    int account = 0;
    if (b > 0 && b < 1500) {
    account += b * 0.03;
    } else if (b > 0 && b < 4500) {
    account += 1500 * 0.03 + (b - 1500) * 0.1;
    } else if (b > 0 && b < 9000) {
    account += 1500 * 0.03 + 3000 * 0.1 + (b - 4500) * 0.2;
    } else if (b > 0 && b < 35000) {
    account += 1500 * 0.03 + 3000 * 0.1 + 4500 * 0.2 + (b - 9000)
    * 0.25;
    } else if (b > 0 && b < 55000) {
    account += 1500 * 0.03 + 3000 * 0.1 + 4500 * 0.2 + 26000 * 0.25
    + (b - 35000) * 0.3;
    } else if (b > 0 && b < 80000) {
    account += 1500 * 0.03 + 3000 * 0.1 + 4500 * 0.2 + 4500 * 0.25 + 26000*0.25
    + 20000*0.3 +(b - 80000) * 0.35;
    } else if (b > 0 && b >= 80000) {
    account += 1500 * 0.03 + 3000 * 0.1 + 4500 * 0.2 + 4500 * 0.25
    + (b - 35000) * 0.3;
    }
            System.out.println(account);
    }
    }
    不懂什么速算扣除数,楼主自己适当加一下,第三题
      

  7.   

    package test;import java.util.Scanner;public class Scan {
    public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    System.out.println("请输入二次的系数");
    int a = sc.nextInt();
    System.out.println("请输入一次的系数");
    int b = sc.nextInt();
    System.out.println("请输入常数");
    int c = sc.nextInt();
    System.out.println("请输入右边等号的常数");
    int d = sc.nextInt();
    double x = 0;
    if(a*x*x+b*x+c==d){
    System.out.println(x);
    }
    }
    }
    第四题。
      

  8.   

    这些程序都是能执行的,不过楼主是想说编译后的.class文件?
    但是,貌似偶不会直接在回答这传文件。
      

  9.   


    第三题加了一些简单的验证,如下:public class GeShui { public static void main(String[] args) { Scanner sc = new Scanner(System.in); // 非负浮点数判断
    String regex = "^\\d+(\\.\\d+)?$";
    int a = 0;
    String str = sc.next(); Pattern pat = Pattern.compile(regex);
    Matcher mat = pat.matcher(str);
    boolean rs = mat.find(); if(!rs){
    System.out.println("请输入合法数值。");
    }else{
    Double i = Double.parseDouble(str);
    if(i-3500<=0){
    a = 0;
    }else if (i - 3500 <= 1500) {
    a = 1;
    } else if (i - 3500 <= 4500) {
    a = 2;
    } else if (i - 3500 <= 9000) {
    a = 3;
    } else if (i - 3500 <= 35000) {
    a = 4;
    } else if (i - 3500 <= 55000) {
    a = 5;
    } else if (i - 3500 <= 80000) {
    a = 6;
    } else {
    a = 7;
    } switch (a) { case 1:
    System.out.println((i - 3500) * 0.03);
    break;
    case 2:
    System.out.println((i - 3500) * 0.10 - 105);
    break;
    case 3:
    System.out.println((i - 3500) * 0.20 - 555);
    break;
    case 4:
    System.out.println((i - 3500) * 0.25 - 1005);
    break;
    case 5:
    System.out.println((i - 3500) * 0.30 - 2755);
    break;
    case 6:
    System.out.println((i - 3500) * 0.35 - 5505);
    break;
    case 7:
    System.out.println((i - 3500) * 0.45 - 13505);
    break;
    default:
    System.out.println("0");
    }
    } }
    }