如果考试成绩为负数,我如何让用户在第二个for循环中重新输入考试成绩? import java.util.Scanner; 公共班级成绩计算器{ 公共静态void main(字符串[]args){ 双examAdd=0; 双examAvg=0; 复试=0;

如果考试成绩为负数,我如何让用户在第二个for循环中重新输入考试成绩? import java.util.Scanner; 公共班级成绩计算器{ 公共静态void main(字符串[]args){ 双examAdd=0; 双examAvg=0; 复试=0;,java,for-loop,input,calculator,negative-number,Java,For Loop,Input,Calculator,Negative Number,如果考试成绩为负数,我如何让用户在第二个for循环中重新输入考试成绩? import java.util.Scanner; 公共班级成绩计算器{ 公共静态void main(字符串[]args){ 双examAdd=0; 双examAvg=0; 复试=0; int j=0; 扫描仪s=新的扫描仪(System.in); 系统输出打印(“请输入学生人数:”); int stuNum=s.nextInt(); 系统输出打印(“请输入考试编号:”); int examNum=s.nextInt();

如果考试成绩为负数,我如何让用户在第二个for循环中重新输入考试成绩?
import java.util.Scanner;
公共班级成绩计算器{
公共静态void main(字符串[]args){
双examAdd=0;
双examAvg=0;
复试=0;
int j=0;
扫描仪s=新的扫描仪(System.in);
系统输出打印(“请输入学生人数:”);
int stuNum=s.nextInt();
系统输出打印(“请输入考试编号:”);
int examNum=s.nextInt();
for(int i=1;i
for(j=0;jimport java.util.Scanner;

public class GradeCalculator {

    public static void main(String[] args) {

        double examAdd = 0;
        double examAvg = 0;
        double exam    = 0;
        int j          = 0;

        Scanner s = new Scanner(System.in);

            System.out.print("Please enter the number of students: ");
            int stuNum = s.nextInt();

            System.out.print("Please enter the number exams      : ");
            int examNum = s.nextInt();


            for (int i = 1; i <= stuNum; i++)  { 
                Scanner readName = new Scanner(System.in); /* had to re-make another scanner, had issues without one inside the for loop JUST with "nextLine()" nothing else*/

                System.out.println("\n--------------------------------------");

                System.out.print("Enter student " + i + "'s name : " );
                String name = readName.nextLine();

                System.out.print("Enter exam scores      : ");

                for (j = 0; j < examNum; j++) {
                    exam = s.nextDouble();
                        examAdd = (examAdd + exam);

                }   
                        examAvg = (examAdd/examNum);

                        System.out.println("Grade Statistics for " + name);
                        System.out.println("  Average     : " + examAvg);

                        if (examAvg <= 100 & examAvg >= 90){
                            System.out.println ("  Letter Grade:  A \n" + "  " + name + " gets 4 stars! ****\n");
                            examAvg = 0; /* Restart the average formula to calculate next students average*/
                            examAdd = 0;
                        }
                        else if (examAvg <= 89.99 & examAvg >= 80){
                            System.out.println("  Letter Grade: B \n" + "  " + name + " gets 3 stars! ***\n");
                            examAvg = 0; /* Restart the average formula to calculate next students average*/
                            examAdd = 0;
                        }
                        else if (examAvg <= 79.99 & examAvg >= 70){
                                System.out.println("  Letter Grade: C \n" + "  " + name + " gets 2 stars! **\n");
                                examAvg = 0; /* Restart the average formula to calculate next students average*/
                                examAdd = 0;
                            }
                        else if (examAvg <= 69.99 & examAvg >= 60){
                                System.out.println("  Letter Grade: D \n" + "  " + name + " gets 1 star! *\n");
                                examAvg = 0; /* Restart the average formula to calculate next students average*/
                                examAdd = 0;
                            }
                        else if (examAvg <= 59.99) {
                            System.out.println("  Letter Grade: F \n" + "  " + name + " gets 0 stars!\n");
                            examAvg = 0;/* Restart the average formula to calculate next students average*/
                            examAdd = 0;
                        }

            }



    }




}
   for (j = 0; j < examNum; j++) {
        exam=-1
        while (exam<0){

            exam = s.nextDouble();
                examAdd = (examAdd + exam);
            if (exam<0) 
                System.out.println("negative write again");

            }

        }
    for (j = 0; j < examNum; j++) {

        while (true){

            exam = s.nextDouble();
                examAdd = (examAdd + exam);
            if (exam<0) 
                System.out.println("negative write again");

            else 
                continue;

        }