键盘录入长方形的长和宽,定义方法计算该长方形的周长,并在main方法中打印周长
package com;
import java.util.Scanner;
public class Demo02 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.println("请录入长:");
int c = sc.nextInt();
System.out.println("请录入宽:");
int k = sc.nextInt();
int zc = zc(c, k);
System.out.println(zc);
}
public static int zc(int c, int k) {
int zc = (c + k) * 2;
return zc;
}
}