成績を取るロジックを作りたい。クラスを使用してユーザーからの入力として合計マークを取得する方法で進み、それがと(両方を含む)Scanner
の間にある場合はマークを検証しています。0
100
マークがこの範囲内にない場合は、「有効なマークを入力してください!!」と出力し、前のステップに戻ってユーザーに再度入力を求めるようにします。
import java.util.Scanner;
class Performance
{
public static void main(String[] aa)
{
Scanner scnr = new Scanner(System.in);
System.out.println("Enter the marks :"); // Line 7
int marks= scnr.nextInt();
if(marks<0 || marks>100)
{
System.out.println("Enter valid marks!!");
}
// Now if this condition is true then I want the control to go again to line 7
// Please suggest me the way to Proceed
}
}
上記のコードの変更を進める方法を提案してください。