本帖最后由 wenjie315130552 于 2011-02-13 15:36:24 编辑

解决方案 »

  1.   

    刚开始学Java你就像偷懒?还是自己做吧,我也是刚开始学Java,睡了,明天起来做这些题。
      

  2.   


    public class CountChar { public static int upperCase = 0;
    public static int lowerCase = 0;
    public static int digital = 0; public static void main(String[] args) {
    String str = "skjHKL131lsdjf";
    char[] c = str.toCharArray();
    for (int i = 0; i < c.length; i++) { if (c[i] > 'a' && c[i] < 'z')
    upperCase++;
    else if (c[i] > 'A' && c[i] < 'Z')
    lowerCase++;
    else
    digital++; } System.out.println("大写字母的个数:" + upperCase);
    System.out.println("小写字母的个数:" + lowerCase);
    System.out.println("数字的个数:" + digital); }}
      

  3.   


    public class cutString {
    public static void main(String[] args) {
    String str = "accpHelloWorldFininaKK";
    char[] c = str.toCharArray(); for (int i = 0; i < c.length; i++) {
    if (c[i] > 'A' && c[i] < 'Z') {
    System.out.print("," + c[i]);
    continue;
    } else
    System.out.print(c[i]);
    }
    }
    }
      

  4.   


    import java.util.regex.Matcher;
    import java.util.regex.Pattern;public class EmailTest { public static void main(String[] args) { String line = "[email protected]";
    parse(line);
    } private static void parse(String line) {
    Pattern p = Pattern.compile("[\\w[.-]]+@[\\w[.-]]+\\.[\\w]+");
    Matcher m = p.matcher(line);
    if (m.find())
    System.out.println(m.group());
    else
    System.out.println("不匹配!!!");
    }}
      

  5.   

    终于都写完了,呵呵 ,楼主参考一下!!!建议楼主多动手,多思考!/**
     * 四舍五入: 任意数字进行四舍五入,要求保留小数位2位,并且从末尾开始四舍五入 比如: 3.149===>3.15 3.1445==>3.15
     * 3.997===>4.00
     */
    public class RoundTest { public static void main(String[] args) {
    double number = 3.1444445;
    String str = String.valueOf(number);
    parse(str);
    } /**
     * 截取str小数点后面两位的所有数字,问保存到另一个 字符串ss中,对ss中的数字从最后位数开始进行判断
     * 如果最后面的数大于等5,则倒数第二个数加1,以此类 推。最后判断小数点后的第三位是否大于等于5,如果是 则str保留到小数点后面两位的数 加
     * 0.01
     * 
     * @param str
     *            进行四舍五入的字符串
     */
    public static void parse(String str) {
    int index = str.indexOf(".");
    String s = str.substring(0, index + 3);
    double digital = Double.parseDouble(s);
    String ss = str.substring(index + 3, str.length());
    int b = 0; if (ss.length() == 1) {
    int c = Integer.parseInt(ss.charAt(0) + "");
    if (c >= 5)
    digital += 0.01;
    } else if (ss.length() > 1) {
    int a = 0;
    for (int i = ss.length() - 1; i > 0; i--) {
    a = Integer.parseInt(ss.charAt(i) + "");
    if (b >= 5) {
    a += 1;
    }
    b = Integer.parseInt(ss.charAt(i - 1) + "");
    if (a >= 5) {
    b += 1;
    }
    }
    if (b >= 5)
    digital += 0.01; } System.out.println(str + "==>" + digital);
    }
    }
      

  6.   

    奶奶的,劳资是不会做吗!我早做了,只是这几道题有很多种做法。拿第二题来说用String做和StringBuffer区别最很大,ZTM一群脑残,无语!
      

  7.   

    第二题用String做:
    public class CutStringTest
    {
    public static void main(String[] args)
    {
    String str = "accpHelloWorldFininaKK";
    for (int i = 0; i<str.length(); i++)
    {
    if(Character.isUpperCase(str.charAt(i)))
    {
    str = str.substring(0,i)+","+str.substring(i,str.length());
    i++;
    }
    }
        String[] strArray = str.split(",");
        for(int i = 0;i<strArray.length;i++)
        {
         System.out.println(strArray[i]);
        }
    }
    }
    用StringBuffer做:
    public class CutStringTest
    {
    public static void main(String[] args)
    {
        StringBuffer str = new StringBuffer("accpHelloWorldFininaKK");
        for(int i = 0;i<str.length();i++)
        {
         if (Character.isUpperCase(str.charAt(i)))
         {
         str.insert(i,",");
         i++;
         }
        }
        String newStr = str.toString();
        String[] strArray = newStr.split(",");
        for (int i = 0; i<strArray.length; i++)
        {
         System.out.println(strArray[i]);
        }
    }
    }
      

  8.   

    来CSDN找答案,那不是跟找枪手考试一样吗...
    计算机专业的?