私は実際に私のプログラムに問題を抱えています。実は私は学校(11年生-短期大学)で勉強しているので、とても簡単な言葉で説明してください。私はクイズ、非常に基本的な学校のプロジェクトを開発しているので、プログラムはこのように進行します...ユーザーに1から4までの数字を入力して自分の選択を入力してもらいたいです。ユーザーにアルファベット、文字、特殊文字、またはその他の番号を入力してほしくない。1-4以外。try and catchを使用してみましたが、例外をスローした後、プログラムが停止します。エラーメッセージSystem.out.println( "無効な入力。1〜4の数字を入力してください");を表示した後でもプログラムコードを実行したい。 サンプルプログラム
import java.io.*;
import java.lang;
public class
{
public static void main()throws IOException
{
InputStreamReader read =new InputStreamReader (System.in);
BufferedReader in =new BufferedReader (read);
System.out.println(" Select your category");
System.out.println(" 1. Food");
System.out.println(" 2. National");
System.out.println("");
System.out.println(" Enter your choice");
int choice=Integer.parseInt(in.readLine());
if(choice==1)//food category
{
int score = 0;
System.out.println("what are dynamites made?");
System.out.println("1. peanuts");System.out.println("2. grapes");
System.out.println("3. flaxseeds");System.out.println("4. fish");
System.out.println(" Enter your choice");
int food1= Integer.parseInt(in.readline());
if(c1=1)
{ System.out.println(" Correct answer");
score=score+10
}
else
{
System.out.println(" Wronge answer");
score=score+0
}
//then i have the second question with the same format
}
if(choice==2)//natioanl category with the same format as above
{//two question with if else statements in them }
}
}// also help me where to add the try and catch statements