Question: Hello. I need help with the following Java Programming problem: Create a CourseException class that extends Exception and whose constructor receives a String that holds

Hello. I need help with the following Java Programming problem: Create a CourseException class that extends Exception and whose constructor receives a String that holds a college courses department (for example, CIS), a course number (for example, 101), and a number of credits (for example, 3).

Create a Course class with the same fields and whose constructor requires values for each field. Upon construction, throw a CourseException if the department does not consist of three letters, if the course number does not consist of three digits between 100 and 499 inclusive, or if the credits are less than 0.5 or more than 6.

Write an application that establishes an array of at least six Course objects with valid and invalid values. Display an appropriate message when a Course object is created successfully and when one is not.

Here is my layout so far

Course.java

public class Course { String department; int courseNumber; double credits; final int DEPT_LENGTH = 3; final int LOW_NUM = 100; final int HIGH_NUM = 499; final double LOW_CREDITS = 0.5; final double HIGH_CREDITS = 6; public Course() { // Write your code here } public Course(String dept, int num, double creditValue) throws CourseException { // Write your code here } public String toString() { // Write your code here } }

---------------------------------------------------------------------------

CourseException.java

public class CourseException extends Exception { public CourseException(String s) { } }

-------------------------------------------------------------------

ThrowCourseException.java

public class ThrowCourseException { public static void main(String[] args) { // Write your code here } }

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!