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). Save the file as CourseException.java. 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. Save the class as Course.java. 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. Save the file as ThrowCourseException.java.  Modify the CourseException class to extend RuntimeException class and identify the differences.

Question

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). Save the file as CourseException.java. 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. Save the class as Course.java. 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. Save the file as ThrowCourseException.java. 

Modify the CourseException class to extend RuntimeException class and identify the differences.

Expert Answer

Want to see the step-by-step answer?

Check out a sample Q&A here.

Want to see this answer and more?

Experts are waiting 24/7 to provide step-by-step solutions in as fast as 30 minutes!*

*Response times may vary by subject and question complexity. Median response time is 34 minutes for paid subscribers and may be longer for promotional offers.
Tagged in
Engineering
Computer Science

Programing Language

Related Computer Science Q&A

Find answers to questions asked by students like you.

Q: When a resource is shared among multiple consumers. Examples include CPU scheduling, Disk Scheduling...

A: Program Plan:- 1. Create the class Process. 2. Define all the following functions:- sertBack(Proces...

Q: Please answer the question posted and give full explanation of the answer. Please past the successfu...

A: Design a Geometry class with the following methods: A static method that accepts the radius of a ci...

Q: Code in c++ using switch/case statements, Im not looking for help using the website..

A: Actually, c++ is a powerful general purpose language.

Q: Write python code Given list: numbers = [120, 200, 100, 50, 150]   Sort the list based on how close ...

A: By default, sort() doesn't need any additional parameters. However, it has two optional parameters.T...

Q: a) Write a method encrypt(String text, int key) that returns a String. This method does two things t...

A: public static String encrypt(String text, int key) {  String temp[] = text.split(" ");  String rever...

Q: Compiler Construction

A: Actually, compiler is a special program that turns the code into machine language.

Q: Convert the given CFG to CNF: a) E-> E+T | T, T-> T*F | F, F -> 0 | 1 | (E) o where the set of termi...

A: X->+ Y->* Z->( P->) E0->ST|RF|0|1|QPE->ST|RF|0|1|QPT->RF|0|1|QPF->0|1|QPQ-&g...

Q: (Given 11/24/20 Homework #4 Due: 12/10/20) Following is a data description of a library: The library...

A: Actually, database is a used to stores the data.

Q: This is the question -  In Chapter 2, you created an application named QuartsToGallonsInteractive th...

A: InputMismatchException occurs when the number entered by the user is of a different data type than t...

Q: This code is all in Java    Need help with the parts that say TODO ---------------------------------...

A: //java souce code import java.awt.*; import java.awt.event.*; import javax.swing.*; import javax.swi...

Q: Binary Tree Concepts 1.) Introduce a maximum priority queue using a.) A binary-tree based heap. Not ...

A: Program Plan:- 1. Initialize all the required header files. 2. Define all the required functions for...

Q: C++ PLEASE INCLUDE COMMENTS   Write one program that does the following: Ask the user for ten (10) ...

A: Actually, program is a executable software that runs on a computer.

Q: Binary Search algorithm has an element given in sequential arrays. We have seen that at the O (logN)...

A: Objective of the question:- To write the pseudo-code of the binary search algorithm if there are mul...

Q: Program In C  Create one function that contains only one for loop to print the passed array of point...

A: #include <stdio.h> //Function declaration void print(char **arrVal, int size); int main() {   ...

Q: Subject:Database

A: E-R Diagram:

Q: Identify the contents of the registers, memory location (C070H), and the flags as the following inst...

A: Given: M=C070 H Now solve the problem: LXI H, 2020H : (load register pair immediately) After executi...

Q: Draw the diagram of given addressing mode. Show it with examples also. 1-  Register Indirect Address...

A: Here, in this addressing mode, the register value acts as the address of the memory where the operan...

Q: Explain the benefits of hierarchial routing in terms of scale and administrative autonomy.Differenti...

A: Note: This question contains the multiple questions. According to the guidelines you will get the an...

Q: Write a menu driven program that allow the user to perform any one of the following operations based...

A: Program: #include<iostream>  //header files  #include<math.h> using namespace std; int m...

Q: Can help in java ? Define a two-dimensional array of names. For each row: • specify the name with th...

A: The main objective of the Main. java program is to create a two-dimensional array of some sample nam...

Q: Only C/C++

A: #include <iostream>using namespace std;// This functions returns the// Maximum no of students ...

Q: please use c++ to answer the following question Use inheritance and classes to represent a deck of p...

A: Actually, inheritance is a acquiring the properties from one class to another class.

Q: If the components of machine cycle are inter-swapped, would that cause any problems? Can we add anot...

A: Actually,, machine cycle has 4 steps Fetch -  Decode -  Execute -  Store -

Q: I* Your solution goes here */ while

A: The given is a java code under file named AutoBidder with below functionality:   1. It has a nextBid...

Q: Today's PCs have many different connections. In order to input information and have corresponding in...

A: Actually, computer is a electronic device. Which takes input and gives output.

Q: Write a program that prompts the user to enter 50 integers and stores them in an array. The program ...

A: Program Plan:- 1. Initialise all the required header files. 2. declare the array of 50 numbers. 3. a...

Q: Prepare a "Functionality Requirement Analysis" document which informs technical people about require...

A: Solution: Requirement Analysis can be stated as the process of  defining user expectations to build ...

Q: Make block diagrams gor 16:1 multiplexers using 8:1 multiplexer and 2:1 multiplexers to design

A: In digital electronics, a multiplexer also called mux receives multiple input signals (both analog o...

Q: Draw the diagram of given addressing mode. Show it with examples also. 1- Direct Addressing

A: DIRECT ADDRESSING MODE: In this addressing mode, 1) The address field of the instruction contains th...

Q: Q7: (Find the second lowest integer number) Write a program that prompts the user to enter a set of ...

A: #include <iostream> using namespace std; int findSecondLowest(int arr[], int n){    int smalle...

Q: Q6: (Display patterns using loops) Use nested loops that display the following pattern in three sepa...

A: Pattern A  : Program in  C #include <stdio.h> int main() {    int i, j, rows;    printf("Enter...

Q: need help with python. Also, can you explain how we have to do this

A: Actually, python is a easiest programming language. It is a dynamically typed programming language. ...

Q: Create a program named TipCalculation that includes two overloaded methods named DisplayTipInfo. One...

A: Program approach: create a class  define two overloaded method named DisplayTipInfo ()  one method ...

Q: (Fall 2020) (Given 11/24/20 Homework #4 Due: 12/10/20) Following is a data description of a library:...

A: Actually, database is used to stores the data.

Q: (b)/Éxplain Dijkstra Algorithm and compute the shortest paths of given Network fig-1. 2 Source Desbn...

A: Introduction of Dijkstra's Algorithm: The Dijkstra's Algorithm is used to find the minimum distance ...

Q: Subject :database

A: The following properties are required to solve the problems in the given scenario: Atomicity, Consis...