Program 1: Writing Your Own Class

The purpose of this assignment is to learn how to write a simple class on your own.PartnersYou may (and are encouraged to) work with at most one other partner on this assignment. You and your partner must be in the same lab section. If you work with a partner, submit one solution with both of your names on it.AssignmentCreate a BlueJ project named Program1. Add a class named Driver and then copy this code into it. Add a second class named Course. You must write the Course class yourself. The three instance variables for Course are
  • name, a String such as "CSCI 111"
  • credits, an integer such as 4
  • costPerCredit, a double such as 200.00
The constructor for the class is
  • public Course(String inName, int inCredits, double inCostPerCredit)
The methods for the class are
  • public String getName() - returns the name of the course
  • public int getCredits() - returns the course credits
  • public double getCostPerCredit() - returns the cost per credit
  • public double getCourseCost() - returns the cost of the course. This can be calculated by multiplying the number of credits for the course by the cost per credit.
Desired OutputIf you have implemented the Course class correctly, this output will be produced when the main method of Driver is run.Grading - 100 points
  • 15 points - the three instance variables are correct (5 points each)
  • 15 points - the constructor is correct
  • 60 points - the four methods are correct (15 points each)
  • 10 points - is commented appropriately
Powered by