For Question 1, please download the file, and work with the existing code as instructed in the question.
To submit the exam, please create a Zip file with the respective answers, labelled by Question number, and send through in a private conversation between yourself and the instructor
Question 1
The file named DistanceDifference.cpp contains an incomplete program that should be able to calculate the distance between a series of geocoded locations. Two parts of the program need to be completed:
1. The portion of the main() function that calculates the distances between each of the hard-coded 5 locations, and stores it in a two-dimensional array declared as distances.
2. A portion of the calculateDistanceBetweenLocations(l1, l2) function; omitted code spaces are designed with a // TODO: comment.
The code is properly commented in order for you to understand exactly what is being done, however you should not touch parts of the program that are not earmarked with a
// TODO: comment.
Question 2
Design and implement a Class called
Course –separated into its respective header (Course.h) and implementation file (Course.cpp).
The class contains a dependency on a Section structure, which should have the following
interface:
struct Section {
string section_code;// Section Code
string days[2];// Array of days section meets per week
string times[2];// Array of times section meets each day
int student_count;// Number of students in the section
}
The class should have the following private variables:
string course_name
long int course_id
string department
string instructor_name
Section *sections
int section_count
The class should have a default constructor that initializes the following variables to the specified values:
course_name = “”
course_id= -1
department = “”
instructor_name = “Baruch Faculty”
sections = nullptr
section_count = 0
The class should have the following public functions(The explanation of the function follows in italics):
?void setCourseInformation(string courseName, long int courseId, string department, string instructorName);
This function sets the class’ private variables to the values passed to the function
?void display CourseInformation() const;
This function outputs the course information, in the following format:
<department> <course_id>: <course_name> by <instructor_name>
?void addClassSection(string sectionCode, string days[], string times[], int studentCount);
This function adds a new section to an array referenced by the sections pointer variable,
and updates the section_count variable.
HINT: When adding a new section, remember that existing sections must be preserved.
?bool removeClassSection(string sectionCode);
This function removes an existing section from the sections array. It should ensure that
the section exists, and if it does it should return TRUE after being removed. If it does not
exist, the function should return FALSE
?int getSectionCount() const;
This function returns the number of sections attached to the course
版权所有:编程辅导网 2021 All Rights Reserved 联系方式:QQ:99515681 微信:codinghelp 电子信箱:99515681@qq.com
免责声明:本站部分内容从网络整理而来,只供参考!如有版权问题可联系本站删除。