明天结贴
要稍详细点
谢谢

解决方案 »

  1.   

    dbclick eclipse.exeCreate Projectinput code
    ... ...
      

  2.   

    package B;import java.util.Scanner;public class TheThreadTest {    public static void main(String args[]) {
            Scanner sc = new Scanner(System.in);        while (true) {
                System.out.println("请输入数字:数字*数字这个格式");
                String s1 = sc.nextLine();
                System.out.println(s1);
                String[] s = s1.split("\\*");
                try {
                    int i = Integer.valueOf(s[0].trim()) * Integer.valueOf(s[1].trim());
                    System.out.println("" + i + "\r\n");
                } catch (Exception e) {
                    System.out.println("你输入的格式不正确," + "\r\n");
                }        }
        }
    }
      

  3.   

    package oop;import java.io.BufferedReader;
    import java.io.IOException;
    import java.io.InputStreamReader;public class Che { /**
     * @param argsChe.java
     */
    public static void main(String[] args) {
    // TODO Auto-generated method stub
    String input="";
    int a=0,b=0;
    int result=0;
    System.out.println("请输入格式为a*b的式子:");
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    try {
    input = br.readLine();
    int i=0;
    i = input.indexOf("*");
    a = Integer.parseInt(input.substring(0, i));
    b = Integer.parseInt(input.substring(i+1, input.length()));
    result = a*b;
    } catch (IOException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
    }
    System.out.println("结果是:"+result);
    }}
    一定要记得加分啊,我都调试过了,完全正确的
      

  4.   


    import java.util.Scanner;public class AmultiplyB { public static void main(String args[]) {
    Scanner sc = new Scanner(System.in); //while (true) {
    System.out.println("Input:Number*Number");
    String s1 = sc.nextLine();
    System.out.println(s1);
    String[] s = s1.split("\\*");
    try {
    int i = Integer.valueOf(s[0].trim())
    * Integer.valueOf(s[1].trim());
    System.out.println("" + i + "\r\n");
    } catch (Exception e) {
    System.out.println("Wrong format," + "\r\n");
    } //}
    }
    }这里直接注释掉while语句也是可行的。
      

  5.   

    不写while的话,你执行一次自己就关闭,为了方便操作多次
      

  6.   

    public static void main(String[] args) {
    String input;
    int a = 0, b = 0;
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    try {
    input = br.readLine();
    int i = input.indexOf("*");
    try {
    a = Integer.parseInt(input.substring(0, i));
    b = Integer.parseInt(input.substring(i + 1, input.length()));
    System.out.println(a * b);
    } catch (StringIndexOutOfBoundsException e) {
    System.out.println("参数不对");
    } catch (NumberFormatException e) {
    System.out.println("数字格式不对");
    } } catch (IOException e) {
    System.out.println("出错了");
    }
    }
      

  7.   

    public static void main(String[] args) {
    String input;
    int a = 0, b = 0;
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    try {
    input = br.readLine();
    int i = input.indexOf("*");
    try {
    a = Integer.valueOf(input.substring(0, i).trim());
    b = Integer.valueOf(input.substring(i + 1).trim());
    System.out.println(a * b);
    } catch (StringIndexOutOfBoundsException e) {
    System.out.println("参数不对");
    } catch (NumberFormatException e) {
    System.out.println("数字格式不对");
    }
    } catch (IOException e) {
    System.out.println("出错了");
    }
    }
      

  8.   

    发觉。楼主的头像的hair style超象anqini。脸架子也有点象。汗
      

  9.   

    答:anqini的代码不错呀。不过,Scanner sc所占用的资源最后应该释放呀
      

  10.   

    public static void main(String args[]) {
            Scanner sc = new Scanner(System.in);        while (true) {
                System.out.println("请输入数字:数字*数字这个格式");
                String s1 = sc.nextLine();
                System.out.println(s1);
                String[] s = s1.split("\\*");
                try {
                    int i = Integer.valueOf(s[0].trim()) * Integer.valueOf(s[1].trim());
                    System.out.println("" + i + "\r\n");
                } catch (Exception e) {
                    System.out.println("你输入的格式不正确," + "\r\n");
                }        }
      

  11.   

    BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); 
    try { 
    input = br.readLine(); 
    int i=0; 
    i = input.indexOf("*"); 
    a = Integer.parseInt(input.substring(0, i)); 
    b = Integer.parseInt(input.substring(i+1, input.length())); 
    result = a*b; 
      

  12.   


    正解,这样不好啊,这些都是基础,也牵扯不到java什么很高深的东西,C里面不也有么
      

  13.   

    楼上的似乎都是java application!
    以下是applet小程序:
    ---------------------------------------------------------------
    import java.applet.*;
    import java.awt.*;
    import java.awt.event.*;
    public class Multiply extends Applet implements ActionListener{
      Label l1=new Label("请输入第一个数: ");
      Label l2=new Label("请输入第二个数: ");
      TextField a=new TextField(15);
      TextField b=new TextField(15);
      Button cal=new Button(" 计算 ");
      Button clear1=new Button(" 清除 ");
      String result="";
      public void init(){
        add(l1);
        add(a);
        add(l2);
        add(b);
        add(cal);
        add(clear1);
        clear1.addActionListener(this);
        cal.addActionListener(this);  }
      public void actionPerformed(ActionEvent e){
        String x=e.getActionCommand();
        double aa=0;
        double bb=0;
        if(x==" 计算 "){
          try{
           aa=Double.valueOf(a.getText()).doubleValue();
           bb=Double.valueOf(b.getText()).doubleValue();
          }catch(Exception ee){}
        result=a.getText()+"*"+b.getText()+"="+Double.toString(aa*bb);
        }
        else{
          a.setText("");
          b.setText("");
          result="";
        }
        repaint();
      }
      public void paint(Graphics g){
        g.drawString(result,20,100);
      }
    }
    ---------------------------------------
    所在的html:
    ---------------------------------------
    <html>
    <body>
    <applet code="Multiply.class" 
            height="200"
            width="300">
    </applet>
    </body>
    </html>