CIS Department Fill Rates (Absolutely no two-dimensional arrays or vectors may be used) Purpose: Under the new De Anza College budgetary measures, fill rates will determine the number of sections offered by a department and whether a given class will be canceled or not. In this program you will write a C++ program to determine fill rates and output reports needed by the CIS department. See file Lab 7FillRates.txt . Use precisely six parallel arrays: string for course CRN number, string for class name (e.g. CIS D002.-62Z), integer for current enrollment, integer for maximum enrollment, integer for number of students on wait-list, and a double for the fill rate which is the current enrollment divided by the maximum enrollment. Warning: avoid integer division truncation issues. An output file is opened in main() and remains open until the end of the execution (see slide 9 of “Everything you need to know about File I/O”). Input: Write a function to input the CRN, the name of the class, the current enrollment, the maximum enrollment, and number of students on wait-list. As you are inputting, compute the fill rate for the class. Repeat until end of file. Assume a maximum of 100 classes. Use getline(file, string name) to input text with spaces such as the name of the class. You will find a very mischievous ‘\n’ character to deal with both after the name of the class and more importantly at the end of the three numerical values. You will enjoy knowing about file.ignore() or for Mac people, declare string temp; and use getline(filename, temp); . Mac users usually are using a text editor that has \r\l i.e. two characters, at the end of each line. Function should return number of classes offered by the CIS department. Output: Write a separate function to output directly to a file all classes giving CRN, name of class, current enrollment, maximum class size, and fill rate as percent. You will need to call this function in processing steps 2 and 6. Processing steps: • Call getData() function from main() to input data filling all six arrays and returning the actual number of classes. • Call the output function from main() to output directly to a file all data in the original order. • Write a separate function to compute and return the average fill rate for all CIS classes. Do not output from this function but return the value and print it out to the screen from main(). • Write a function to prompt the user for double value representing a fill rate minimum. Output to the file from this function all information for each class with a fill rate below this value or if there are none output “No classes with fill rate below XX”. This function is called from main(). • In main prompt the user for the CRN number of a class. Write a function called from main() that searches for this class and returns the location (subscript) of the element which has this CRN number. Upon return to main() output the name of the class and the fill rate or the words "NO SUCH CLASS!" • Use a selection sort to sort class by fill rate in ascending order. This is written as a separate function with no output and called from main(). • Call the output function again (do not write another output function) to write the sorted array to the file. THEME ISSUES: one-dimensional arrays, if statements, file input, file output, searching, sorting Absolutely no two-dimensional arrays, no structures and no menu function. Sample output before sorting: CRN Course Current Max Number on Fill Enrollment Enrollment Wait-list Rate % 00469 CIS D002.-62Z 27 40 0 67.5 00471 CIS D003.-02Y 22 40 0 55.0 00472 CIS D003.-03Y 14 40 0 35.0 . . . 02644 CIS D21JA-01Y 40 40 5 100.0 22853 CIS D21JA-02Y 40 40 12 100.0 23989 CIS D21JA-62Y 36 40 0 90.0
ANSWER:
#include <iostream>
#include <fstream>
using namespace std;
const int MAX=100;//assumed that maximum 100 entries
int getData(ifstream &infile,string CRN[],string
className[],int cEnroll[],int maxEnroll[],int waitingList[],double
fillRate[]); //function reads input from file
void outputData(ofstream &outfile,string CRN[],string
className[],int cEnroll[],int maxEnroll[],int waitingList[],double
fillRate[],int size); //function outputs to a file
double computeAvgFillRate(double fillRate[],int count);//function
to compute and return the average fill rate for all CIS
classes
void printMinFillRate(string CRN[],string className[],int
cEnroll[],int maxEnroll[],int waitingList[],double fillRate[],int
count); //function outputs the courses below the specified fill
rate
void sort(string CRN[],string className[],int cEnroll[],int
maxEnroll[],int waitingList[],double fillRate[],int count);
//selection sort by fill rate
int main()
{
//code here
//declare local variables with constant maximum
string CRN[MAX],className[MAX];
int cEnroll[MAX],maxEnroll[MAX],waitingList[MAX];
double fillRate[MAX];
ifstream input("Lab7FillRates.txt");//open file for reading
int size; //required for returning
size=getData(input,CRN,className,cEnroll,maxEnroll,waitingList,fillRate);//call
function to read input
cout<<"\nTotal records : "<<size;
input.close();//close the input file
cout<<"\nAverage of all Filling rate :
"<<computeAvgFillRate(fillRate,size);//call function to print
average fill rate
printMinFillRate(CRN,className,cEnroll,maxEnroll,waitingList,fillRate,size);//call
function to print courses below min fill rate
sort(CRN,className,cEnroll,maxEnroll,waitingList,fillRate,size);//call
function to selection sort
ofstream output("Lab7output.txt");//open file for writing
cout<<"\nSorted Data : ";
outputData(output,CRN,className,cEnroll,maxEnroll,waitingList,fillRate,size);//call
it for output
cout<<"\nData is written in Lab7output.txt";
output.close();//close the output file
return 0;
}
//function reads input from file
int getData(ifstream &infile,string CRN[],string
className[],int cEnroll[],int maxEnroll[],int waitingList[],double
fillRate[])
{
//code here
int count=0; //initial count is 0
string temp;
//reading first record
infile>>CRN[count];//read CRN number
getline(infile,className[count]);//read a line of course or class
name
infile>>cEnroll[count]>>maxEnroll[count]>>waitingList[count];//read
other fields
fillRate[count]=(double)cEnroll[count]/maxEnroll[count]*100;//calculate
fill rate
while(!infile.eof()) //read until end of file
{
//reading next records
//getline(infile,temp);//blank line skip here
count++;//move to next
infile>>CRN[count];//read CRN number
getline(infile,className[count]);//read a line of course or class
name
infile>>cEnroll[count]>>maxEnroll[count]>>waitingList[count];//read
other fields
fillRate[count]=(double)cEnroll[count]/maxEnroll[count]*100;//calculate
fill rate
}
return count;//finally return count of records
}
//function outputs to a file
void outputData(ofstream &outfile,string CRN[],string
className[],int cEnroll[],int maxEnroll[],int waitingList[],double
fillRate[],int size)
{
//code here
for(int i=0;i<size;i++)//repeat all records
{
cout<<"\n"<<CRN[i]<<"
"<<className[i]<<" "<<cEnroll[i]<<"
"<<maxEnroll[i]<<" "<<waitingList[i]<<"
"<<fillRate[i];
outfile<<"\n"<<CRN[i]<<"
"<<className[i]<<" "<<cEnroll[i]<<"
"<<maxEnroll[i]<<" "<<waitingList[i]<<"
"<<fillRate[i]; //write the content to file
}
}
//function to compute and return the average fill rate for all
CIS classes
double computeAvgFillRate(double fillRate[],int count)
{
//code here
double avg=0;
for(int i=0;i<count;i++) //repeat all fill rates
avg+=fillRate[i];//add each fill % rate
return avg/count; //return average
}
//function outputs the courses below the specified fill
rate
void printMinFillRate(string CRN[],string className[],int
cEnroll[],int maxEnroll[],int waitingList[],double fillRate[],int
count)
{
//code here
double min;//local variable
bool flag=false;
cout<<"\nEnter minimum fill rate : ";
cin>>min;
for(int i=0;i<count;i++) //repeat all arrays
{
if(fillRate[i]<min) //when below minimum is found
{
cout<<"\n"<<CRN[i]<<"
"<<className[i]<<" "<<cEnroll[i]<<"
"<<maxEnroll[i]<<" "<<waitingList[i]<<"
"<<fillRate[i]; //print it
flag=true; //make it found flag is true
}
}
if(!flag) //when not found
cout<<"\nNo classes with fill rate below "<<min;
//print error message
}
//selection sort by fill rate
void sort(string CRN[],string className[],int cEnroll[],int
maxEnroll[],int waitingList[],double fillRate[],int count)
{
//code here
int min_idx=0;//initial min index 0
// One by one move boundary of unsorted subarray
for (int i = 0; i <count-1; i++)
{
// Find the minimum element in unsorted array
min_idx = i;
for (int j = i+1; j < count; j++)
if (fillRate[j] < fillRate[min_idx]) //compare fill rates
min_idx = j;
// Swap the all fields
string tCRN=CRN[min_idx];
CRN[min_idx]=CRN[i];
CRN[i]=tCRN;
string tClass=className[min_idx];
className[min_idx]=className[i];
className[i]=tClass;
int tEnroll=cEnroll[min_idx];
cEnroll[min_idx]=cEnroll[i];
cEnroll[i]=tEnroll;
int tMaxEnroll=maxEnroll[min_idx];
maxEnroll[min_idx]=maxEnroll[i];
maxEnroll[i]=tMaxEnroll;
int tWaiting=waitingList[min_idx];
waitingList[min_idx]=waitingList[i];
waitingList[i]=tWaiting;
double tFillRate=fillRate[min_idx];
fillRate[min_idx]=fillRate[i];
fillRate[i]=tFillRate;
}
}
OUTPUT SCREENSHOT:

CIS Department Fill Rates (Absolutely no two-dimensional arrays or vectors may be used) Purpose: Under the...
Use
c++ as programming language. The file needs to be created ourselves
(ARRAYS) Write a program that contains the following functions: 1. A function to read integer values into a one-dimensional array of size N. 2. A function to sort a one-dimensional array of size N of integers in descending order. 3. A function to find and output the average of the values in a one dimensional array of size N of integers. 4. A function to output a one-dimensional...
C++ Please Contact list - functions & parallel arrays/CStrings No Vectors can be used since we haven't learned them yet !! A contact list is a place where you can store a specific information with other associated information such as a phone number, email address, birthday, etc. Write a program that will read 5 data pairs into two parallel arrays. Data pairs consist of a name (as a CString) and a GPA (double). That list is followed by a name,...
CIS 22A C++ Project Exam Statistics Here is what your program will do: first it welcomes the user and displays the purpose of the program. It then prompts the user to enter the name of an input file (such as scores.txt). Assume the file contains the scores of the final exams; each score is preceded by a 5 characters student id. Create the input file: copy and paste the following data into a new text file named scores.txt DH232 89...
This project will allow you to practice with one dimensional arrays, function and the same time review the old material. You must submit it on Blackboard and also demonstrate a run to your instructor. General Description: The National Basketball Association (NBA) needs a program to calculate the wins-losses percentages of the teams. Write a complete C++ program including comments to do the following: Create the following: •a string array that holds the names of the teams •an integer array that...
Write a C program (not C++) that calls a function to multiply a matrix (two dimensional array). The main program should ask the user to enter an integer that will be used as the matrix “adder” and then call the function. The function should perform a matrix increment (every element of the array is incremented by the same value) and assign the result to another array. The function should be flexible enough to work with any array size and “adder”,...
c++ help
Write a program that: Creates two finite arrays of size 10 These arrays will serve as a storing mechanism for student grades in Classes A and B Uses a loop to populate the arrays with randomly generated numbers from 0 to 100.These numbers will represent student grades. Compute average grade of each class. Finally, output the two arrays and the message with two averages and best class. ("Class A average is: 65.43; class B average is: 68.90. Class...
Write a menu based program implementing the following functions: (0) Write a function called displayMenu that does not take any parameters, but returns an integer representing your user's menu choice. Your program's main function should only comprise of the following: a do/while loop with the displayMenu function call inside the loop body switch/case, or if/else if/ ... for handling the calls of the functions based on the menu choice selected in displayMenu. the do/while loop should always continue as long...
Need help Purpose Calculate mileage reimbursements using arrays and methods. The Mathematical Association of America hosts an annual summer meeting. Each state sends one official delegate to the section officers’ meeting at this summer session. The national organization reimburses the official state delegates according to the scale below. Write a Java program to calculate the reimbursement values, satisfying the specifications below. Details on array and method usage follow these specs. 1. The main method should declare all the variables at...
Exercise #1: Design and implement a program (name it AssignGrades) that stores and processes numeric scores for a class. The program prompts the users to enter the class size (number of students) to create a single-dimensional array of that size to store the scores. The program prompts the user to enter a valid integer score (between 0 and 100) for each student. The program validates entered scores, rejects invalid scores, and stores only valid scores in the array. The program...
Implement the following class in interface and implementation files. A separate file (the main project file) shall have the main function that exercises this class. Create a class named Student that has three member variables: name - string that stores the name of the student numClasses - integer that tracks how many courses the student is currently enrolled in, this number must be between 1 and 100 ClassList - an array of strings of size 100 used to store the...