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!

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]);

}

}

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!