写一个Java应用程序,输入一个数求其平方和立方

package day20170107;


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;


class InputData {
public static String string = null;


public static void input() {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
try {
string = br.readLine();
} catch (IOException e) {
// TODO 自动生成的 catch 块
e.printStackTrace();
}
}


public static int getInt() {
input();
return Integer.parseInt(string);
}
}


class Result {
public void print(int d) {
System.out.println("d的平方:" + d * d);
System.out.println("d的立方:" + d * d * d);
}


}


public class SquareAndCube {
public static void main(String[] args) {
Result result = new Result();
System.out.println("请输入你要操作整形数字:");
int d = InputData.getInt();
result.print(d);
}
}

你可能感兴趣的:(算法面试)