Skip to content

Instantly share code, notes, and snippets.

@nshiba
Created June 13, 2014 17:05
Show Gist options
  • Save nshiba/666d6c1ac3703afd84a0 to your computer and use it in GitHub Desktop.
Save nshiba/666d6c1ac3703afd84a0 to your computer and use it in GitHub Desktop.
package ex5;
import java.util.Scanner;
public class CalcAreaOfCircle {
/**
* @param args
*/
public static void main(String[] args) {
// TODO 自動生成されたメソッド・スタブ
CalcAreaOfCircle c = new CalcAreaOfCircle();
while (true) {
Scanner s = new Scanner(System.in);//数字入力の準備
int radius = s.nextInt();
c.calc(radius);
}
}
public void calc(int radius) {//面積を計算するメソッド
double answer = radius * radius * Math.PI;
System.out.println(answer);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment