题目
设计程序,
创建一个整型变量toes,
并将toes设置为10,
程序中还要计算toes的两倍,和toes的平方,
该程序应打印三个值,并分别将这三个值打印在三行(注意),
每一行都要说明打印的数字的含义。
如:
toes:10
toes的两倍:20
toes的平方:100
代码
public class Homework0415 {
public static void main(String[] args) {
//声明变量
int toes = 10; //声明赋值
int toes1 = toes * 2; //两倍
double toes2 = Math.pow(toes, 2); //平方
//输出
System.out.println( "声明初始值toes =" + toes);
System.out.println( "计算toes的两倍 =" + toes1);
System.out.println( "计算toes的平方 =" + toes2);
}
}