Write a test program for tracking their course sections

Assignment Help Data Structure & Algorithms
Reference no: EM131321625

Programming Assignment: Data Structures

A college wants to you to write a test program for tracking their course sections.

Classroom capacities on campus range from a minimum of 1 student to a maximum of 30 students.

Data stored about each course includes: the course number, the course title, the capacity (number of seats) for the course, the number of students enrolled in the course, and a list of student ids for students enrolled in the course.

Class Details

The following data members must be declared as part of the new class, course.

Data Field Data Type
course number string (2 uppercased letters followed by 3 digits)
course title string
capacity integer (between 1 and 30)
number students enrolled integer (between 0 and capacity)
student id list array of 5-digit student ids (size = maximum course capacity)

The following member functions must be declared as part of the new class, course.

Two constructor functions (one without parameters, and one with parameters)

Constructor without parameters will set the initial values to:
course number to " "
course title to " "
capacity to minimum capacity of a classroom
number students enrolled to 0

Constructor with parameters will provide the following parameters and default values:
course number (no default - must be supplied)
course title (no default - must be supplied)
capacity = (default = maximum capacity)
The number students enrolled will not be a parameter, and this constructor will set it to 0.

Mutator functions (assign values to data members)
setCourseNum
setCourseTitle
setCapacity

Accessor functions (access values from data members)
getCourseNum
getCourseTitle
getCapacity
getNumEnrolled

Facilitator functions:
printCourse (display course data)
printStudentIds (display all student ids on student id list)
addOneStudent (add one student to course)
dropOneStudent (drop one student from course)

Operator overloading functions:
operator++ (increment capacity by one)
operator<< (displays object data)

NOTE: Data members within the course type class may only be accessed via the above member functions.

You will also need to define several functions outside of the class, for reading and error checking user input and managing the courses.

Program Details

When the program begins, it will create three course type objects as follows:

Create using the constructor with parameters to set the course number and course title to CS361, Control Structures (will use the default capacity).

Create using the constructor with parameters to set the course number and course title to CS362, Data Structures, and set the capacity to 10.

Create using the constructor without parameters.

After course3 is created, prompt the user for the course number and course title, and assign them to the object data fields.

When all three courses objects have been created, the program will allow the user to manipulate the objects.

The program will access the course number and course name in each of the course objects to present a Choose Course menu to the user for choosing a course to manage.

The Choose Course menu must be implemented so that the user enters either a course number or E to exit.

Example:

Choose a course to manage:
CS361 - Control Structures
CS362 - Data Structures
MT415 - Linear Algebra
Enter the course number (e.g. CS200) or E to exit:

After the user chooses a course to manage, the program will display a Course Management menu of actionchoices, as detailed on the next page.

The actions will be applied to the course that was chosen to be managed.

Course Management menu choices:

P - Print course data (to the screen)

Use the overloaded << operator to display the course data as follows:

CS361 - Control Structures:

1 seats taken, out of 15 total seats

N - Modify course Number

Call a function to read, error check, and return a valid course number.

Course numbers must be 2 letters followed by 3 digits. If a course number entered by the user is invalid, issue an error message stating why it is invalid. Loop and re-prompt for the course number, until it is valid.

The function should uppercase the letters, if user enters them in lowercase, before returning the value.

Then use setCourseNum to store the new value, and then confirm the change.

Example:
New course number is CS430
T - Modify course Title

Call a function to read, error check, format, and return a valid course title (i.e. course name).

Course titles can contain only letters and spaces. If a title entered by the user is invalid, issue an error message stating why it is invalid. Loop and re-prompt for the title, until it is valid.

NOTE: In order to read the title, you will need to use getline (covered in text Chapter 3) because the extraction operator (>>) will only read strings up to the first whitespace.

After error checking the title characters, format the title. The first letter and each letter following a space will be uppercased, and the rest will be lowercased. Return the valid formatted title.

Then use setCourseTitle to store the new value, and confirm the change.

Example:
New course title is Operating Systems

C - Modify course Capacity

Call a function to read, error check, and return a valid course capacity. The function should insure that the new capacity is within the minimum and maximum allowable capacity.

Using the returned value, check to insure the new capacity is not less than the current student enrollment (use getNumEnrolled to check the current enrollment).

If the new value is below the current number of students enrolled, issue a message saying that students must be dropped from the course first.

Example:

Error - cannot change capacity to 20 unless 2 students are dropped, because 22 students are already registered.

Otherwise, use setCapacity to store the new value and confirm the change.

Example:

Capacity is now 11

I - Increment course Capacity

Use the overloaded ++ operator to increment the course capacity by one, as long as it does not exceed the maximum capacity allowed, and then confirm change.

Example:

Capacity is now 12

S - Student Management

Display a Student Management sub-menu (display student ids, add one student, drop one student, and return back to the Course Management menu).

The options should be implemented as follows:

P - Print Student IDs (to the screen)

Use printStudentIds to display the ids of students enrolled in the course,

one student per line.

Example:

2 students enrolled in CS361
77777
87228

A - Add one student

If course is full, issue an error message.

Example:

Course is full. Cannot add any more students.

Otherwise, use addOneStudent to add one student to the course, as follows:

Call an input function to read, error check, and return a valid student ID (must be a 5digit integer, no leading zeros allowed).

Then store the student id number in the list, increment the student enrollment, and Confirm the change.

If the course is empty, simply display a message stating there are no students enrolled.

Example:
Cannot drop a student -- no students are enrolled.

Otherwise, use dropOneStudent to drop one student from the course, as follows:

a) Display the student ids
b) Ask the user for the student id number of the student to drop
c) Find the student id number in the list
d) If the student id number is found, delete the id from the list and decrement the enrollment.

Reminder: Deleting from unordered arrays was covered in online content sections 3.4.3 and 3.4.4.

e) Display a message confirming which student id number was dropped, or stating that the student id number could not be found.

B - Back to Course Management menu

Exit the Student Management menu and return to the Course Management menu.

Loop around the Student Management menu options, until the user chooses B.

[END of Student Management menu options]

B - Back to Choose Course menu

Exit the Course Management menu and return to the Choose Course menu.

Loop around the Course Management menu options, until the user chooses B.

The program will loop around the Choose Course menu, until the user chooses Exit.

NOTE: For each menu, when a menu choice is entered, the program will error check the user has entered a valid choice, and will issue an error message if the choice is not valid.

Before exiting the program, use the overloaded << operator again to display the course data for all three courses.

Program Notes:

1. Your program must conform to all CS362 Coding Standards specified in Content section 1.7.

- The program should include a file header at the top of each program file
- Each function should include a function header.

2. This program should be of modular design (minimum of FIFTEEN functions/methods).

- The breakdown of the code must be logical, not arbitrary!

Unauthorized distribution (including uploading to any non-Regis Internet website) violates copyright law

- The main function should do little more than call other functions.
- The other functions/methods should each perform ONE well-defined task.

3. Your program should be thoroughly tested, and test data files should be submitted.

Reference no: EM131321625

Questions Cloud

Analyze inventory valuation methods : Analyze inventory valuation methods discussed in the textbook. Based on your analysis, recommend the most accurate valuation method that reflects current economic conditions. Provide a rationale for your recommendation
What is present value of this investment : An investment will pay $2,566 two years from now, $2,243 four years from now, and $2,639 five years from now. If the opportunity rate is 6.98 percent per year, what is the present value of this investment?
Discuss the merits and demerits of computer freezing : One of the methods used in extracting computer forensics evidence is to freeze the computer. While this is considered a good approach by many people, there are those who think it is shoddy work. Discuss the merits and demerits of computer "freezin..
Write a function that creates a file with two nicely columns : Write a function that creates a file with two nicely formatted columns containing the t values to the left and the corresponding y values to the right. Let the t values appear in increasing order.
Write a test program for tracking their course sections : A college wants to you to write a test program for tracking their course sections. Classroom capacities on campus range from a minimum of 1 student to a maximum of 30 students.
Present value and future value of this cash flow stream : Claire Conscience has shares of an oil well that only occasionally generates any income. Her projections are that she will receive $200 in year 1, $1,000 in year 3, and $500 in year 4. If Claire’s opportunity cost is 5.5%, what is the present value a..
What is a bastion router : Search and discuss as many services and protocols as possible offered by a modern firewall.
Pressure inside the eardrum does not change : Assume that the air pressure inside and out are balanced when you leave Denver, the pressure inside the eardrum does not change, and that the density of the air is constant and is equal to 0.80 kg/m3.
Fast-growing firm recently paid a dividend : A fast-growing firm recently paid a dividend of $0.80 per share. The dividend is expected to increase at a 15 percent rate for the next three years. Afterwards, a more stable 11 percent growth rate can be assumed. If a 12 percent discount rate is app..

Reviews

Write a Review

Data Structure & Algorithms Questions & Answers

  Designing an algorithm for task-array of person numbers

You have been allotted task of designing an algorithm for following task. Someone has built the array of person numbers of all n students enrolled in 331 this fall.

  Design a divide-and-conquer algorithm

Design a divide-and-conquer algorithm for the Motif Finding problem and estimate its running time. Have you improved the running time of the exhaustive search algorithm?

  Find the kth largest value in an unsorted array of n element

find the kth largest value in an unsorted array of N elements. Estimate the running time. It should be better than quick sort running time.

  Draw the process tree and expected output

Draw the process tree and expected output, Repeat the exercise using 3 instead of 2 in the for statement

  Creating java program using two arrays

Create a program in Java which defines 2-unconstrained arrays of user defined length n, that contain n Random numbers each and which outputs addition of pairs of elements.

  Write an algorithm, using pseudo code, "consensus algorithm"

Write an algorithm, using pseudo code, "Word Search": Given a string of letters, identify all substrings that create one of five given words.

  Describe how you plan to search for the sudoku solution

Describe how you plan to search for the Sudoku solution given a starting state. Clearly define your state space here: What does a vertex in your state traversal tree represent?

  Define the degree of a node in a tree

Define the degree of a node in a tree as the number of its nonempty children. Thus, for a binary tree, the degree of a node is 0, 1 or 2.

  Draw a structured flowchart or write pseudocode

Draw a structured flowchart or write pseudocode that describes the process of looking up a word in a dictionary. Pick a word at random and have a fellow student attempt to carry out your instructions

  What is the data type

What is the data type and What is the type of the parameter

  What is your recommendation for alamo foods

Given a discount rate of 9 percent (.09), perform present value analysis on the data for Alamo Foods. (Hint: Use the formula 1/ (1 + i)n to find the multipliers for years 1 to 6.), What is your recommendation for Alamo Foods?

  Briefly define the caesar cipher

What are the two basic functions used in encryption algorithms and how many keys are required for two people to communicate via a cipher?

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd