Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Need help on java project please comment and explain somewhere on the code too.

ID: 3669225 • Letter: N

Question

Need help on java project please comment and explain somewhere on the code too. Thank you

Here are the sample output

https://gyazo.com/7d520abc4d295e747b1e1c662fe5f6e4

And for the CourseDriver file

part 1.

https://gyazo.com/a72a787131d5d7b2ece6f7f2cec3939d

part 2

https://gyazo.com/0e4216dab0ddd784374a3cc5a38b3c29

Part 1: Bank Account (50 points)

Write a class to describe a BankAccount object. A bank account is described by:

the account owner's name

an account ID (stored as text)

the balance in the account

BankAccount Class (35 points)

In your class, include:

instance data variables

two constructors

one constructor takes an initial balance; the second constructor opens an account with no money

getters and setters

include appropriate value checks when applicable

a toString method

you can decide the output

a deposit method

include appropriate value checks

a withdrawal method

include appropriate value check

Driver Program (15 points)

Write a driver program to demonstrate your class, including:

creating bank account objects using both constructors

making deposits and withdrawals (with both valid and invalid values)

invoking other methods

Note: your driver program does not need to be interactive with the user. It only needs to create objects and invoke methods on those objects to demonstrate that your class works.

Extra Credit (5 points)

Include an interest rate as part of what describes a bank account. Update the BankAccount class as necessary. You should be able to adjust the interest rate and add interest. Add code to the driver program to demonstrate the interest rate functionality.

Notes

For full credit, follow good principles of programming and object-oriented design.

Part 2: Course Registration (50 points)

Write a Student and Course class that might be part of a course registration system.

A student is described by:

first name

last name

student ID (as text)

whether or not tuition is paid

A course is described by:

a name

the maximum number of students that can be enrolled in the class

a roster of students enrolled in the course (stored as a Student[])

Student Class (10 points)

In your class, include:

instance data variables

a constructor

getters and setters

a toString method

Course Class (40 points)

In your class, include

instance data variables

a constructor

a course is initially created with no students on the roster

getters and setters

this about which variables should have setters

include validity checks where appropriate

a toString method

an addStudent method

method header: public boolean addStudent(Student student)

if there is room for a student and the student has paid their tuition, add the student to the roster

a dropStudent method

method header: public boolean dropStudent(Student student)

if the student is on the roster, remove them

a toString method

include the name, number of students enrolled in the course, maximum number that can be enrolled, and a printed roster as part of the text representation

make sure that the roster does not print any "nulls"

Notes

You can include additional instance data variables if it is helpful. If you include additional variables, include additional getters and setters as appropriate.

I have provided a driver program you can use to test your code and sample output.

I also provided the sample output generated from the driver program.

You might add additional code to the driver to run additional tests to make sure your classes work.

For full credit, follow good principles of programming and object-oriented design.

Extra Credit (15 points)

Write a class called CourseAL. This class has the same methods as Course. Instead of using a Student[] to store the roster, use an ArrayList<Student>. For full credit, take advantage of the methods in the ArrayList class to implement the methods.

Note: If completing the extra credit, you must submit both the Course and CourseAL classes.

Explanation / Answer

Part A. BankAccount

package chegg;

public class BankAccount
{
   private double balance;
   private String id;
   private String name;

   public BankAccount( String i, String name) {
       this.balance = 0;
       this.id = i;
       this.name = name;
   }
  
   public BankAccount(double balance, String id, String name) {
       this.balance = balance;
       this.id = id;
       this.name = name;
   }

   public void deposit(double amount)
   {
       balance = balance + amount;
   }

   public void withdraw(double amount)
   {
       if((balance-amount) < 0)
           System.out.println("Insufficient Balance");
       else
           balance = balance - amount;
   }

   public double getBalance()
   {
       return balance;
   }

   /**
   * @return the id
   */
   public String getId() {
       return id;
   }

   /**
   * @return the name
   */
   public String getName() {
       return name;
   }

   /**
   * @param balance the balance to set
   */
   public void setBalance(double balance) {
       this.balance = balance;
   }

   /**
   * @param id the id to set
   */
   public void setId(String id) {
       this.id = id;
   }

   /**
   * @param name the name to set
   */
   public void setName(String name) {
       this.name = name;
   }
   @Override
   public String toString() {
       return "[Name: "+name+", Id: "+id+", Balance: "+balance+"]";
   }
  
}

class Driver{
   public static void main(String[] args) {
       BankAccount b1 = new BankAccount("ABC3", "Alex");
       BankAccount b2 = new BankAccount(200, "2CD", "Bob");
       System.out.println(b1.toString());
       System.out.println(b2.toString());
   }
  
}

Part B: CourseRegistration

import java.util.ArrayList;

public class CourseAL {
   int capacity;
   int registered;
   String name;
   ArrayList<Student> students = new ArrayList<Student>();
  
   /**
   * @param capacity
   * @param registered
   * @param name
   * @param students
   */
   public CourseAL(int capacity, String name) {
       this.capacity = capacity;
       this.name = name;
   }
   /**
   * @return the capacity
   */
   public int getCapacity() {
       return capacity;
   }
   /**
   * @return the registered
   */
   public int getRegistered() {
       return registered;
   }
   /**
   * @param capacity the capacity to set
   */
   public void setCapacity(int capacity) {
       this.capacity = capacity;
   }
   /**
   * @param registered the registered to set
   */
   public void setRegistered(int registered) {
       this.registered = registered;
   }
   public void register(Student s){
       if(registered == capacity){
           System.out.println("Roster is full");
           return;
       }
       students.add(s);
       registered++;
   }
   @Override
   public String toString() {
       return "[Name: "+name+", Capacity: "+capacity+", Registered: "+registered+"]";
   }
}

class Student{
   String name;
   int id;
   Student(String name, int id){
       this.name = name;
       this.id = id;
      
   }
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote