1.

public class test1 {

    /**
     * @param args
     */
    public static void main(String[] args) {
        // TODO Auto-generated method stub
        int a,b,c,n;
        n=345;
        a=n/100;
        b=n%100/10;
        c=n%100%10;
        System.out.println(a+b+c);
                
    }

}

 

 

2.

public class test1 {

    /**
     * @param args
     */
    public static void main(String[] args) {
        // TODO Auto-generated method stub
        double x,y;
        x=36;
        y=x*9/5;
        System.out.println(y);
                
    }

}

 

 3.

package work_oc;

public class work_3 {

    public static void main(String[] args) {
        // TODO Auto-generated method stub
        int a=5;
        int b=8;
        int c;
        System.out.println("交换前a,b的值分别为"+a+"和"+b);
        c=a;
        a=b;
        b=c;
        System.out.println("交换后a,b的值分别为"+a+"和"+b);
    }

}

 

 4.

package work_oc;

public class work_4 {

    public static void main(String[] args) {
        // TODO Auto-generated method stub
        int n=12141;
        System.out.println("五位数为:"+n);
        int a;
        a=n-(n%100);
        System.out.println("保留至百位后:"+a);
    }

}

 

 5.

package work_oc;

public class work_5 {

    public static void main(String[] args) {
        // TODO Auto-generated method stub
        int a=1234;
        System.out.println("其各位数总和为\n");
        int b,c,d,e;
        b=a/1000;
        e=a%10;
        c=a/100-b*10;
        d=(a%100-e)/10;
        System.out.println(b+c+d+e);
    }

}

 

 6.

package work_oc;

public class work_6 {

    public static void main(String[] args) {
        // TODO Auto-generated method stub
        int field='A';
        System.out.println("其小写为");
        field=field+32;
        System.out.println((char)field);
    }

}

 

posted on 2021-03-14 23:48  李昌璇  阅读(31)  评论(0编辑  收藏  举报