C8_Project (1) [Java Application] C:\Program Files\Javaljre1.8.0_131\bin\javaw.exe (Mar 26, 2019, 12:55:57 PM) Enter classes remaining and taking each term for student 1: 8 2 Enter classes remaining and taking each term for student 2: 15 3 Enter classes remaining and taking each term for student 3: 6 1 Enter classes remaining and taking each term for student 4: 12 6 The number of classes per term for student 4 is not valid! Enter classes remaining and taking each term for student 4: 12 5 Enter classes remaining and taking each term for student 5: 13 2 Enter classes remaining and taking each term for student 6: 7 3 Enter classes remaining and taking each term for student 7: 9 4 Enter classes remaining and taking each term for student 8: 3 2 Enter classes remaining and taking each term for student 9: 5 4 Enter classes remaining and taking each term for student 10: 18 3 AMPLE. Student 1 needs 4 tess to graduate Student 2 needs 5 terms to graduate Student 3 needs 6 terms to graduate Student 4 needs 3 terms to graduate Student 5 needs 7 terms to graduate Student 6 needs 3 terms to graduate Student 7 needs 3 terms to graduate Student 8 needs 2 terms to graduate Student 9 needs 2 terms to graduate Student 10 needs 6 terms to graduate Enter classes remaining and taking each term for student 1: 8 2 Enter classes remaining and taking each term for student 2: 15 3 Enter classes remaining and taking each term for student 3: 6 1 Enter classes remaining and taking each term for student 4: 12 5 Enter classes remaining and taking each term for student 5: 13 2 Enter classes remaining and taking each term for student 6: 7 3 Enter classes remaining and taking each term for student 7: 9 4 Enter classes remaining and taking each term for student 8: 3 2 Enter classes remaining and taking each term for student 9: 5 4 Enter classes remaining and taking each term for student 10: 18 3 Student 1 needs 4 terms to graduate Student 2 needs 5 terms to graduate Student 3 needs 6 terms to graduate Student 4 needs 3 terms to graduate Student 5 needs 7 terms to graduate Student 6 needs 3 terms to graduate Student 7 needs 3 terms to graduate Student 8 needs 2 terms to graduate Student 9 needs 2 terms to graduate Student 10 needs 6 terms to graduate
Write a program that determines how many terms 10 students need to graduate.
- Define a two-dimension array with 10 rows and 2 columns.
- Prompt the user to enter the number of courses they have left to graduate (value must be between 1 and 20) and how many courses they plan to take each term (value must be between 1 and 5). If the user enters either value out of range then the user must be prompted to reenter.
- The program must store the number of courses a student has left and how many courses they plan to take each term in a different row of the array, i.e. the first student’s number of courses and how many they plan to take each term will be stored in first row of array. The second student’s info will be in second row, and so on.
- The program must compute the number of terms a student has remaining, and this should be an integer. For example, if a student has 15 courses remaining and plans to take 2 a term then they need 8 terms to complete the courses. In other words, you can have 7.5 terms because the student must attend an entire term.
Images inculded are a sample from the professor and one I have made
What I have thus far
import java.util.Scanner;
import java.lang.Math;
public class Project
{
public static void main(String[] args)
{
Scanner input=new Scanner(System.in);
int[][] students = new int[10][2];
//prompt user to enter number of courses left and courses to take each term.
for(int i=0; i<10; i++)
{
System.out.print("\n Enter classes remaining and taking each term for student "+(i+1)+": ");
students[i][0]=input.nextInt();
students[i][1]=input.nextInt();
}
//calculate and print number of terms left
for(int i=0; i<10; i++)
{
int terms= (int)Math.ceil((double)students[i][0]/(double)students[i][1]);
System.out.print("\n Student "+(i+1)+ " needs " + terms + " terms to graduate");
}
}
}
![<terminated> C8_Project (1) [Java Application] C:\Program Files\Javaljre1.8.0_131\bin\javaw.exe (Mar 26, 2019, 12:55:57 PM)
Enter classes remaining and taking each term for student 1: 8 2
Enter classes remaining and taking each term for student 2: 15 3
Enter classes remaining and taking each term for student 3: 6 1
Enter classes remaining and taking each term for student 4: 12 6
The number of classes per term for student 4 is not valid!
Enter classes remaining and taking each term for student 4: 12 5
Enter classes remaining and taking each term for student 5: 13 2
Enter classes remaining and taking each term for student 6: 7 3
Enter classes remaining and taking each term for student 7: 9 4
Enter classes remaining and taking each term for student 8: 3 2
Enter classes remaining and taking each term for student 9: 5 4
Enter classes remaining and taking each term for student 10: 18 3
AMPLE.
Student 1 needs 4 tess to graduate
Student 2 needs 5 terms to graduate
Student 3 needs 6 terms to graduate
Student 4 needs 3 terms to graduate
Student 5 needs 7 terms to graduate
Student 6 needs 3 terms to graduate
Student 7 needs 3 terms to graduate
Student 8 needs 2 terms to graduate
Student 9 needs 2 terms to graduate
Student 10 needs 6 terms to graduate](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2F9f4ea7c7-22da-4de1-aa57-51c0851ab99c%2F335eba73-8069-4a21-ad2e-f78118719a31%2F6sdmh6p.png&w=3840&q=75)


Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 1 images









