Provide Best Programming Tutorials

## ( 显示三条消息）编写程序，显示Welcome to ]ava、Welcome to Andrew Programming 和 Programming is fun！

```public class E1_01 {

public static void main(String[] args) {
System.out.println("Welcome to Java");
System.out.println("Welcome to Computer Science");
System.out.println("Programming is fun");
}
}```

## (显示五条消息）编写程序，显示Welcome to Java 五次您的答案

```public class E1_02 {
public static void main(String[] args) {
System.out.println("Welcome to Java.");
System.out.println("Welcome to Java.");
System.out.println("Welcome to Java.");
System.out.println("Welcome to Java.");
System.out.println("Welcome to Java.");
}
}```

## (数列求和）编写程序，显示1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 的结果。

```public class E1_03 {
public static void main(String[] args) {
int result = 0;
for (int i = 1; i <= 9; i++) {
result += i;
}
System.out.println(result);
}
}```

## (圆的面积和周长）编写程序，使用以下公式计算并显示半径为 5.5 的圆的面积和周长。

```周长=2 x 半径 x π

```public class E1_04 {

public static void main(String[] args) {
double perimeter = perimeter(5.5);
double area = area(5.5);
System.out.println("perimeter: " + perimeter);
System.out.println("area: " + area);
}

private static double perimeter(double radius) {
return 2 * radius * Math.PI;
}

private static double area(double radius) {
}
}```

## ( 矩形的面积和周长）编写程序，使用以下公式计算并显示宽度为 4.5 、高度为7.9 的矩形的面积和周长。

`面积= 宽x高`
```public class E1_05 {

public static void main(String[] args) {
System.out.println("area: " + area(4.5, 7.9));
System.out.println("perimeter: " + perimeter(4.5, 7.9));
}

private static double area(double width, double height) {
return width * height;
}

private static double perimeter(double width, double height) {
return 2 * (width + height);
}
}```

## (人口估算）

• 每7 秒有一个人诞生
• 每13 秒有一个人死亡
• 每45 秒有一个移民迁人

```public class E6_11 {

public static void main(String[] args) {
System.out.println("Population projection");
System.out.println("Current population: 312032486");
System.out.println("One birth every 7 seconds.");
System.out.println("One death every 13 seconds.");
System.out.println("One new immigrant every 45 seconds.");
System.out.println("Yearly Population projection formula: ");
System.out.println("Current population + ((births per year)");
System.out.println("                   - (deaths per year)");
System.out.println("                   + (new immigrants per year))");
System.out.println("                   * year.");
System.out.println("Year 1 projection: ");
System.out.println(312032486 + (((31536000 / 7)
- (31536000 / 13)
+ (31536000 / 45)) * 1));
System.out.println("Year 2 projection: ");
System.out.println(312032486 + (((31536000 / 7)
- (31536000 / 13)
+ (31536000 / 45)) * 2));
System.out.println("Year 3 projection: ");
System.out.println(312032486 + (((31536000 / 7)
- (31536000 / 13)
+ (31536000 / 45)) * 3));
System.out.println("Year 4 projection: ");
System.out.println(312032486 + (((31536000 / 7)
- (31536000 / 13)
+ (31536000 / 45)) * 4));
System.out.println("Year 5 projection: ");
System.out.println(312032486 + (((31536000 / 7)
- (31536000 / 13)
+ (31536000 / 45)) * 5));
}
}```