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

Problem: Given the year and day number of that year on which the fall semester b

ID: 3598524 • Letter: P

Question

Problem: Given the year and day number of that year on which the fall semester begins, determine the calendar date of the start of the semester, when October Break will take place, and when the Thanksgiving Break will occur. The starting date must be a Monday (see example #5), October Break is always during Monday and Tuesday of the 8th week of the semester, and Thanksgiving will take place on the fourth Thursday in November with the day before and after being a part of the break. . Several formulas necessary for this problem can be found on page 300 of your C programming text. Example Execution #1: Enter the year 2017 Enter the day number on which the fall semester begins: 233 Semester start date: 08/21/2017 October Break 2017: 10/09 -10/10 Thanksgiving Break 2017: 11/22 -11/24 Example Execution #2: Enter the year: 2018 Enter the day number on which the fall semester begins: 232 Semester start date: 08/20/2018 October Break 2018: 10/08 - 10/09 Thanksgiving Break 2018: 11/21 -11/23 Example Execution #3: Enter the year: 2019 Enter the day number on which the fall semester begins: 231 Semester start date: 08/19/2019 nctoher Brea 201 10/0710/08

Explanation / Answer

package com;
public class DList<T> {
private DNode<T> header, trailer;
private int size;
public DList() {
size = 0;
header = new DNode<T>(null, null, null);
trailer = new DNode<T>(null, header, null);
header.setNext(trailer);
}
// utility methods
public int size() {
return size;
}
public boolean isEmpty() {
return size == 0;
}
// give clients access to nodes, but not to the header or trailer
public DNode<T> getFirst() throws Exception {
if (isEmpty())
throw new Exception("Empty");
return header.getNext();
}
public DNode<T> getLast() throws Exception {
if (isEmpty())
throw new Exception("Empty");
return trailer.getPrev();
}
public DNode<T> getNext(DNode<T> v) throws Exception {
DNode<T> ans = v.getNext();
if (ans == null || ans == trailer)
throw new Exception("No such node");
return ans;
}
public DNode<T> getPrev(DNode<T> v) throws Exception {
DNode<T> ans = v.getPrev();
if (ans == null || ans == header)
throw new Exception("No such node");
return ans;
}
// methods to change the list
public void addBefore(T d, DNode<T> v) {
DNode<T> u = v.getPrev();
DNode<T> x = new DNode<T>(d, u, v);
u.setNext(x);
v.setPrev(x);
size++;
}
public void addAfter(T d, DNode<T> v) {
DNode<T> w = v.getNext();
DNode<T> x = new DNode<T>(d, v, w);
v.setNext(x);
w.setPrev(x);
size++;
}
public void addFirst(T d) {
addAfter(d, header);
}
public void addLast(T d) {
addBefore(d, trailer);
}
public T remove(DNode<T> v) throws Exception {
if (v == header || v == trailer)
throw new Exception("Sentinel");
DNode<T> u = v.getPrev();
DNode<T> w = v.getNext();
w.setPrev(u);
u.setNext(w);
size--;
return v.getData();
}
// LinkedList testing methods:
public String toString() {
String ans = "";
DNode<T> n = header;
ans += "(H)<-->";
do {
n = n.getNext();
if (n == trailer)
ans += "(T)";
else
ans += (n.getData() + "<-->");
} while (n != trailer);
return ans;
}
}

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