Question: 2 part a question java 1 Question 4 (15+8 Points) Part (1) Define a class with the following specification: a. The class name is Course.

Question 4 (15+8 Points) Part (1) Define a class with the following specification: a. The class name is Course. It has three private instance variables code (String), credits (int) and grade (char). b. Write a constructor that accepts the code, number of credits and a grade of a course. If credit parameter is negative, set credits to zero and if grade parameter is not A, B, C, or D, set grade to F. Assume that all grades are in uppercase. c. Write a public getter and setter for credits variable. In the setter method, keep credits unchanged in case the input parameter is negative. d. Write a public method called weight() that returns the course weight. The course weight is computed by multiplying the course credits with grade points (ie weight = course credis x grade points) according to the table below: Grade AB CDF Points 4.0 3.0 2.0 1.0 0.0 Write a public method called printinfo() that displays all the instance variables. An example is shown below: Sample Output: Code: ITCS113 Credits: 3 Grade: B Part (2) Write a Java application to do the following: a Create two objects from the class Course One for ITCS113 with number of credits is 5 and grade is A, and the other is for PHYSC101 with number of credits is 2 and grade is C. b. Change the credit hours for ITCS113 to 3 and PHYSC101 to 4. Print the course info for both courses. d. Compute and print the GPA for the two courses using the equation: Course 1 weight + Course 2 weight Course 1 credits + Course 2 credits GPA
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
