私のプログラムでは、ユーザーによる整数入力が必要です。ユーザーが整数ではない値を入力したときにエラー メッセージを表示したい。これどうやってするの。私のプログラムは、円の面積を見つけることです。半径の値を入力するユーザー。しかし、ユーザーが文字を入力すると、無効な入力というメッセージが表示されます。
これは私のコードです:
int radius, area;
Scanner input=new Scanner(System.in);
System.out.println("Enter the radius:\t");
radius=input.nextInt();
area=3.14*radius*radius;
System.out.println("Area of circle:\t"+area);