Function Requirements Your program will be driven by a menu prompt. The menu ite
ID: 3619856 • Letter: F
Question
Function Requirements
Your program will be driven by a menu prompt. The menu items are add TA, name lookup, course lookup, time lookup, and quit. All input in this entire program is case sensitive. The main menu should re-prompt on invalid input.
TA Office Hour Program
1. Add TA
2. Name lookup
3. Course ID lookup
4. Time lookup
5. Quit
Add TA
Prompts for first name, last name, number of courses (up to 5), course ID for each course, number of office hours (up to 10), day and start time for each office hour. Your program should be able to handle up to 200 TAs. We assume that, regardless of start time, an office hour last for exactly 1 hour. For example:
First Name: John
Last Name: Doe
Number of courses: 2
ID for course 1: CS201
ID for course 2: CS251
Number of office hour intervals: 3
Day (MTWRFS) and time for office hour 1: M:08:00
Day (MTWRFS) and time for office hour 2: M:13:30
Name lookup
Print all of the information for each TA whose first or last name begins with the given characters. If the input is “Jo” then both “John Doe” and “Bob Jolly” would be matches to the query. If there are no matches, a message is displayed stating that there are no matches. In either case the main menu is displayed immediately afterwards.
Enter Search String: Jo
John Doe
CS201 CS251
M:08:00 M:13:30 W:11:00
CS100
T:09:00 T:10:00
Time lookup
Get course ID, day, and time as input. Print all the information for each TA that has the given course ID in his or her course array and also has an office hour that contains the given time on the given day. If the time is invalid an error message is displayed. In either case, the main menu is displayed immediately afterwards.
Enter Search String: W:11:49
M:08:00 M:13:30 W:11:00
Mary Jane
CS123 CS456
W:11:30 F:12:00
Implementation Requirements
You will declare a SimpleTime class to keep track of military time (00:00-23:59) and day of the week (MTWRFS). There are no office hours on Sunday. See the lab for 8/11 for more details on the SimpleTime class. You will declare a TA class with data members for first name, last name, an array of strings holding up to 5 course IDs, an int holding the actual number of courses, an array of Times holding up to 10 office hour times, and an int holding the actual number of office hours.
public void print(); //in TA class
Explanation / Answer
please rate - thanks import java.util.*;import java.io.*;
public class TA {
private String firstName;
private String lastName;
private String[] courseIds = new String[5];
private int coursesCount;
private Time[] times = new Time[10];
private int timesCount;
public TA(String firstName, String lastName, String[] courseIds, int coursesCount, Time[] times, int timesCount) {
this.firstName = firstName;
this.lastName = lastName;
this.courseIds = courseIds;
this.coursesCount = coursesCount;
this.times = times;
this.timesCount = timesCount;
}
public String getFirstName() {
return firstName;
}
public void setFirstName(String firstName) {
this.firstName = firstName;
}
public String getLastName() {
return lastName;
}
public void setLastName(String lastName) {
this.lastName = lastName;
}
public String[] getCourseIds() {
return courseIds;
}
public void setCourseIds(String[] courseIds) {
this.courseIds = courseIds;
}
public int getCoursesCount() {
return coursesCount;
}
public void setCoursesCount(int coursesCount) {
this.coursesCount = coursesCount;
}
public Time[] getTimes() {
return times;
}
public void setTimes(Time[] times) {
this.times = times;
}
public int getTimesCount() {
return timesCount;
}
public void setTimesCount(int timesCount) {
this.timesCount = timesCount;
}
public void printInfo() {
System.out.println(" First name: " + firstName);
System.out.println("Last name: " + lastName);
System.out.print("Courses:");
for (int i = 0; i < coursesCount; i++) {
if (i > 0) {
System.out.print(", ");
}
System.out.print(courseIds[i]);
}
System.out.print(" Time intervals: ");
for (int i = 0; i < timesCount; i++) {
if (i > 0) {
System.out.print(", ");
}
times[i].printInfo();
}
}
} ------------------------------------------
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.