Java第二次作业

package homework2;

public class Test1 {

    /**
     * @param args
     */
    public static void main(String[] args) {
        // TODO Auto-generated method stub
        double r = 1;
        double s;
        s = 3.14 * r * r;
        System.out.println(s);

    }

}

package homework2;

public class Test2 {

    /**
     * @param args
     */
    public static void main(String[] args) {
        // TODO Auto-generated method stub
        float hua = 50, a;
        a = (hua - 32) * 5 / 9;
        System.out.println("华氏温度转摄氏温度为" + a);
        float she = 30, b;
        b = she * 9 / 5 + 32;
        System.out.println("摄氏温度转华氏温度为" + b);
    }

}

package homework2;

public class Test3 {

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

}

 

 

 

 

 

 

package homework2;

public class Test4 {

    /**
     * @param args
     */
    public static void main(String[] args) {
        // TODO Auto-generated method stub 
        int a = 12345;
        int b;
        b = a / 100 * 100;
        System.out.println(b);

    }

}

 

 

 

 

package homework2;

public class Test5 {

    /**
     * @param args
     */
    public static void main(String[] args) {
        // TODO Auto-generated method stub
        int a = 345;
        int ge, shi, bai, sum;
        ge = a % 10;
        shi = a / 10 % 10;
        bai = a / 100;
        sum = ge + shi + bai;
        System.out.println("各位数的和为" + sum);
    }

}

 

 

package homework2;

public class Test6 {

    /**
     * @param args
     */
    public static void main(String[] args) {
        // TODO Auto-generated method stub
        char a = 'T';
        System.out.println((char) (a + 32));
        char b = 'm';
        System.out.println((char) (b - 32));
    }

}

 

posted @ 2021-03-12 11:15  樽梦  阅读(67)  评论(0编辑  收藏  举报