subject

Create a CourseException class that extends Exception and whose constructor receives a String that holds a college course’s 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.

These must be in three different "files" as well as being written in java
Here is the code 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) {
return
}
}

//ThrowCourseException. Java//

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

ansver
Answers: 3

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 22:30
What is the most popular genre of video games?
Answers: 1
question
Computers and Technology, 24.06.2019 08:00
Can someone work out the answer as it comes up in one of my computer science exams and i don't understand the cryptovariables
Answers: 1
question
Computers and Technology, 25.06.2019 02:30
Ahammer should not be applied to the gear shafts of an electric rotisserie because the shafts may be made of
Answers: 1
question
Computers and Technology, 25.06.2019 04:10
This might be a bit off-topic, but i'm having trouble with a certain arg made by game theory. if there are any theorists out there that wanna , it would be appreciated!
Answers: 2
You know the right answer?
Create a CourseException class that extends Exception and whose constructor receives a String that h...
Questions
question
Mathematics, 12.03.2021 18:20
question
Physics, 12.03.2021 18:20
question
French, 12.03.2021 18:20
Questions on the website: 13722362