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

Other questions on the subject: Computers and Technology

image
Computers and Technology, 21.06.2019 21:30, khikhi1705
What elements related to the release and success of the nes console do you see in modern console releases? what elements are no longer relevant to modern console gaming?
Answers: 3
image
Computers and Technology, 23.06.2019 23:30, jamalchris9353
Worth 50 points answer them bc i am not sure if i am wrong
Answers: 1
image
Computers and Technology, 24.06.2019 00:00, Kaylaonfleek0956
Consider the series where in this problem you must attempt to use the ratio test to decide whether the series converges. compute enter the numerical value of the limit l if it converges, inf if it diverges to infinity, minf if it diverges to negative infinity, or div if it diverges but not to infinity or negative infinity.
Answers: 1
image
Computers and Technology, 24.06.2019 10:10, nakeytrag
Which view in a presentation program displays a split window showing the slide in the upper half and a blank space in the lower half?
Answers: 1
You know the right answer?
Create a CourseException class that extends Exception and whose constructor receives a String that h...

Questions in other subjects:

Konu
Social Studies, 08.01.2020 05:31