Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I finished a code and was wondering how do you make a printed statement saying \

ID: 3918028 • Letter: I

Question

I finished a code and was wondering how do you make a printed statement saying "the number of classes for student %d is not valid!" and then make the code say "Enter classes and graduation year for student %d : the number of classes for student %d is not valid!" then go back to normal like "Enter classes and graduation year for student %d : "

here is the code

import java.util.Scanner;

public class Chpt8_Project {

public static void main(String[] args) {

int[][] arr = new int [10][2];

Scanner in = new Scanner(System.in);

for(int i = 0; i < 10; i++)

{

System.out.printf("Enter classes and graduation year for student %d : ", i+1);

arr[i][0] = in.nextInt();

arr[i][1] = in.nextInt();

while(arr[i][0] > 20 || arr[i][0] < 1)

{

System.out.printf("Enter valid courses left for graduation for student %d : ", i+1);

arr[i][0] = in.nextInt();

}

}

for(int i = 0; i < 10; i++)

{

System.out.printf("Student %d requires %d credits to graduate in year %d ", i+1, arr[i][0]*3, arr[i][1]);

}

}

}

Explanation / Answer

Following is the answer: