College of Winston and Charlotte
This program will calculate the amount for a semester bill at The College of Winston and Charlotte.
Part 1:
Create a class Course.java:
The class has non-static instance variables:
The class must have a default constructor which will set values as follows:
The class must have a non-default constructor which will set values as follows (use the setters):
The class must have the appropriate getter and setter methods. The setter methods must trap the user to enter valid information as follows:
The class must have a toString method and an equals method.
Part 2:
Create a LabCourse.java which is a subclass of Course.java.
LabCourse.java adds $100 to the courseCost.
The class must have the appropriate default and non-default constructors.
Getter and setter methods are not needed.
The class must have a toString method and an equals method. Both of those methods must override the inherited toString and equals methods.
A course is a lab course if the department is COMP, SCIE, PHYS
Part 3:
Develop a program (DemoWinstonAndCharlotte_yourInitials.java, where yourInitialsrepresents your initials) that asks the user for the number of courses they will take, creates an array of Courses, gets the information for each course (department, courseNumber, courseCredits), creates instances of the appropriate class, populates the array with the instances, calculates the cost of each course and the total bill and then prints the information for each course and the total of the bill to the user.
Thanks for the question, The whole assignment is too big. Given the limited time, I have coded the Part 1 and Part 2, I could not finish off the Part 3. Please post Part 3 as a separate post and I will help you with it. Sorry for the incovenience caused here.
Here are the two classes for Part 1 and Part 2
===========================================================================
import java.util.Objects;
public class Course {
private String department;
private int courseNumber;
private int courseCredits;
private double courseCost;
public Course() {
department = "unknown";
courseNumber = 0;
courseCost = 0;
courseCredits = 0;
}
public Course(String department, int courseNumber, int courseCredits) {
setDepartment(department);
this.courseNumber = courseNumber;
this.courseCredits = courseCredits * 500 / 2;
this.courseCost = courseCost;
}
public String getDepartment() {
return department;
}
public int getCourseNumber() {
return courseNumber;
}
public int getCourseCredits() {
return courseCredits;
}
public double getCourseCost() {
return courseCost;
}
public void setCourseNumber(int courseNumber) {
if (1 <= courseNumber && courseNumber <= 399)
this.courseNumber = courseNumber;
}
public void setCourseCredits(int courseCredits) {
if (3 <= courseCredits && courseCredits <= 6) {
this.courseCredits = courseCredits;
courseCost = courseCredits * 500 / 2;
if (department.equals("COMP") || department.equals("SCIE") || department.equals("PHYS")) {
this.department = department;
courseCost += 100;
}
}
}
public void setDepartment(String department) {
if (department.equals("ENGL") || department.equals("MATH") ||
department.equals("HIST") ||
department.equals("HUMN") ||
department.equals("LANG"))
this.department = department;
else if (department.equals("COMP") || department.equals("SCIE") || department.equals("PHYS")) {
this.department = department;
courseCost += 100;
}
}
@Override
public String toString() {
return
"Department: " + department +
", Course Number: " + courseNumber +
", Credits: " + courseCredits +
", Cost $" + courseCost;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
Course course = (Course) o;
return courseNumber == course.courseNumber &&
courseCredits == course.courseCredits &&
Double.compare(course.courseCost, courseCost) == 0 &&
Objects.equals(department, course.department);
}
}
===================================================================
public class LabCourse extends Course {
public LabCourse() {
super();
}
public LabCourse(String department, int courseNumber, int courseCredits) {
super(department, courseNumber, courseCredits);
}
@Override
public String toString() {
return "Lab Course: " + super.toString();
}
@Override
public boolean equals(Object o) {
if (o != null && o instanceof LabCourse) {
return super.equals(o);
} else {
return false;
}
}
}
===================================================================
College of Winston and Charlotte This program will calculate the amount for a semester bill at...
You are to create a class Appointment.java that will have the following: 5 Instance variables: private String month private int day private int year private int hour private int minute 1 default constructor public Appointment() 1 non-default constructor that accepts arguments for all instance variables, your constructor must call the setter methods below to set the values of the instance variables public Appointment(String monthPassed, int dayPassed, int yearPassed, int hourPassed, int minutePassed) 5 setter methods (one for each instance variable)...
Hello. I need help writing the following Java Program. Thank you Develop a class encapsulating the concept of a college course, assuming that a course has following attributers: code (for instance COSC1337), a description, and a number of credits (for instance 3). Include a constructor, the accessors, mutators and methods ‘toString’, ‘equals’, and ‘finalize’. Write a client class to test the behavior of the class and its methods. The outline of the class is given as follows: public class Course...
Write a program that implements a Course class. Write a demo class that implements two instances of the Course class. The Course class shall have the following member properties and methods: Course - courseName: String - courseAbbr: String - courseNumber: int - courseSection: int - maxNumOfStudents: int + numberOfCourseInstances: int + Course (courseName: String, courseAbbr: String, courseNumber: int, courseSection: int) : void + setCourseName(courseName: String) : void + setCourseAbbr (courseAbbr : String): void + setCourseNumber (courseNumber : int): void +...
In Java*
Please implement a class called "MyPet". It is designed as shown
in the following class diagram.
Four private instance variables: name (of the type String),
color (of the type String), gender (of the type char) and weight(of
the type double).
Three overloaded constructors:
a default constructor with no argument
a constructor which takes a string argument for name, and
a constructor with take two strings, a char and a double for
name, color, gender and weight respectively.
public...
Help with this coding assignment for C++! Add any comments for
better understanding.
Create a class named CupCake. It contains: • Has private instance variables 1. egg 2. butter 3. baking powder 4. sugar 5. flour 6. milk • All members must have public methods: getter() and setter(). • A constructor - a default constructor with no arguments. The constructor will initial all member variable to a default value 0. • One public pure virtual function showingredients() that returns void....
Java Eclipse Coding question: Use data abstraction (real-world modeling) to come up with 3 instance variables and 2 effectors for a new data type – the class HospitalPatient. You have the freedom to design the instance variables and effectors. instance variables effectors 1. 1. 2. 2. 3. Write the code for class HospitalPatient, according to the requirement above. Include the default constructors with no argument, and the constructor with all arguments. Provide a getter and setter for each individual instance...
Please submit a .cpp file or upload zip if you have more than one file before the time up. No library function is allowed. ***The code must contain your name and has proper format. Create a class named CupCake. It contains: • Has private instance variables 1. egg 2. butter 3. baking powder 4. sugar 5. flour 6. milk • All members must have public methods: getter() and setter(). • A constructor - a default constructor with no arguments. The...
Create a C++ console program that defines a class named EvenNumber that represents an even number. Create the class inside a separate header file (.h) and then include this header in your main source code file. The class should have one private integer data field to store the even number. The default constructor should initialize the data field to 0. Also define a 1-arg constructor that initializes the object with the specified value. Define a public getter method named getValue...
JAVA programing Question 1 (Date Class): 5 Points Create a class Date with the day, month and year fields (attributes). Provide constructors that: A constructor that takes three input arguments to initialize the day, month and year fields. Note 1: Make sure that the initialization values for the day, month and year fields are valid where the day must be between 1 and 31 inclusive, the month between 1 and 12 inclusive and the year a positive number. Note 2:...
Given a class called Student and a class called Course that
contains an ArrayList of Student. Write a method called
getDeansList() as described below. Refer to Student.java below to
learn what methods are available.
I will paste both of the simple .JAVA codes below
COURSE.JAVA
import java.util.*;
import java.io.*;
/******************************************************
* A list of students in a course
*****************************************************/
public class Course{
/** collection of Students */
private ArrayList<Student> roster;
/*****************************************************
Constructor for objects of class Course
*****************************************************/...