Java程序第二次作业

package com.homework02;

public class Main {
    public static void main(String[] args) {
        float radius = 10.0f;
        float area;
        float pi = 3.1415926f;


        area = pi * radius * radius;
        System.out.println(area);
    }
}

package com.homework02;

public class Main {
    public static void main(String[] args) {
        double fahrenheit = 50;
        double degree = (fahrenheit - 32.0f) * 9.0f / 5.0f;
        System.out.printf("摄氏度: %f\n", fahrenheit, degree);
        degree = 20;

        fahrenheit = degree * 9 / 5 + 32;
        System.out.printf("华氏度: %f\n", degree, fahrenheit);
    }
}

package com.homework02;

public class Main {
    public static void main(String[] args) {
        int a = 0;
        int b = 1;
        int c = 0;
        c = a;
        a = b;
        b = c;
    }
}

package com.homework02;

public class Main {
    public static void main(String[] args) {
        int n = 12345;
        int target = (n - (n % 100));
        System.out.println(target);
    }
}

package com.homework02;

public class Main {
   public static void main(String[] args) {
        int n = 345;
        int target = 0;
        if (n == 1000) {
            System.out.println(1);
            return;
        }
        int fr;
        for (int m = 0; m < 4; m++) {
            target += (n % 10);
            n = n / 10;
        }
        System.out.println(target);
    }   
}

package com.homework02;

public class Main {
    public static void main(String[] args) {
        char letter = 'A';
        letter += 32;
        System.out.println(letter);

        letter = 'a';
        letter -= 32;
        System.out.println(letter);
    } 
}

posted @ 2021-03-15 11:50  SuoJing  阅读(57)  评论(0编辑  收藏  举报