Question

Write a program that determines how many terms 10 students need to graduate.

Step 1. Create an algorithm (either flowchart or pseudocode) that you will use to write the program. Place the algorithm in a Word document.

Step 2. Code the program in Eclipse and ensure the following steps are accomplished.

1.  Define a two-dimension array with 10 rows and 2 columns.

2.  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.

3. 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.

4. 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.

Step 3. Test your program using this data.

Student 1, 8 courses and plans to take 2 a term

Student 2, 15 courses and plans to take 3 a term

Student 3, 6 courses and plans to take 1 a term

Student 4, 12 courses and plans to take 6 a term             note: error because 6 is too many courses per term

Student 4, 12 courses and plans to take 5 a term            

Student 5, 13 courses and plans to take 2 a term

Student 6, 7 courses and plans to take 3 a term

Student 7, 9 and plans to take 4 a term

Student 8, 3 and plans to take 2 a term

Student 9, 5 courses and plans to take 4 a term

Student 10, 18 courses and plans to take 3 a term

Your output should look like the sample below. Use the Snipit tool in Windows or a similar tool on the Mac to cut and paste t

0 0
Add a comment Improve this question Transcribed image text
Answer #1

import java.util.Scanner;

public class Main {
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++) {
do {
System.out.print("Enter classes remaining and taking each term for student " + (i + 1) + ": ");
arr[i][0] = in.nextInt();
arr[i][1] = in.nextInt();
if(arr[i][0] < 1 || arr[i][0] > 20) {
System.out.println("The number of remaining classes for student " + (i + 1) + " is not valid");
i--;
}
if(arr[i][1] < 1 || arr[i][1] > 5) {
System.out.println("The number of classes per term for student " + (i + 1) + " is not valid");
i--;
}
} while (arr[i][0] < 1 || arr[i][0] > 20 || arr[i][1] < 1 || arr[i][1] > 5);
}

for (int i = 0; i < 10; i++) {
int terms = (int)Math.ceil(Double.valueOf(arr[i][0]) / arr[i][1]);
System.out.println("Student " + (i + 1) + " needs " + terms + " terms to graduate");
}
}
}

Add a comment
Know the answer?
Add Answer to:
Write a program that determines how many terms 10 students need to graduate. Step 1. Create...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT