Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Securing SQL Server Protecting Your Database From Attackers

Authors: Denny Cherry

3rd Edition

0128012757, 978-0128012758

More Books

Students also viewed these Databases questions

Question

3. How did you come to work in social media?

Answered: 1 week ago

Question

2. Do you find change a. invigorating? b. stressful? _______

Answered: 1 week ago

Question

10. Are you a. a leader? b. a follower? _______

Answered: 1 week ago