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

This is a short C++ Programming assignment. I really need help on this. The 1st

ID: 3742797 • Letter: T

Question

This is a short C++ Programming assignment. I really need help on this. The 1st photo is a picture of the directions of the program, the second picture will be the information given to enter into the program, and the last section is a template in which the program needs to be written in. Thank you!

/**************************************************************************
Program Title: Process Program
Description: This program manages an I/O process list and a ready process
list for an OS. The program will manipulate the lists based
on a process requirements from a loaded file.
***************************************************************************/

#include <iostream>
#include <string>
#include <fstream>
#include <time.h>
#include <sstream>

using namespace std;

struct processType
{
unsigned int id;  //Process ID
string name;   //Process name
unsigned int runTime; //Process Running Time
};

class processes
{
public:

void loadList();      //Load process lists into list array
void insertList();  //Insert a process into a process list
void deleteProcess();    //Delete a process from a process list
void retrieveProcess();    //Retrieve and print an individual a process from a process list
void printProcessList();    //Prints a proces from a process list
processes();       // Default Constructor

private:

processType listAry[200];  //Input/Ouput array list
int size;      //Variable to hold size of arrays
void printList() const;   //Prints processes of a list
};

processes::processes()
{
size = 0;      //Initialize size
}

void processes::loadList()
{
ifstream infile;
string filename;

cout << " Enter the process file name (i.e. process.dat): ";
cin >> filename;

infile.open(filename);
size = 0;
while (!infile.eof())
{
  infile >> listAry[size].id;
  infile >> listAry[size].name;
  infile >> listAry[size].runTime;
  size++;
}
infile.close();
}

void processes::printList() const
{
cout << " Processes List" << endl;

for (int i = 0; i < size; i++)  //Loop to print array
{
  cout << "ID: " << listAry[i].id
   << " Name: " << listAry[i].name
   << " Run Time: " << listAry[i].runTime << endl;
}
}

void processes::insertList()
{
int tempID, tempRT;
string tempName;

//Create ID
cout << "Please enter the process ID: ";
cin >> tempID;

//Create process ID name
cout << "Please enter the process ID Name (i.e. pID) ";
cin >> tempName;

//Create run time
cout << "Please enter the runTime: ";
cin >> tempRT;

listAry[size].id = tempID;   //Assign TempID to size.id location
listAry[size].name = tempName;  //Assign tempName to tempName location
listAry[size].runTime = tempRT;  //Assign tempRT to runTime location
size++;

cout << " Updated process list: " << endl;
printList();
}

void processes::deleteProcess()
{
int delProcess;

cout << " Please enter the process ID to delete (i.e. 23)" << endl;
cin >> delProcess;

int pos = -1;  //Variable holds position in array
bool found;   //variable for found value

found = false;

for (int i = pos; i < size; i++)
{
  if (delProcess == listAry[i].id)  ///Compare each id with desired deleted ID
  {
   found = true;
   pos = i;
  }
}

if (found == false)
  std::cout << "Sorry, no processes can be deleted" << endl;

else if (found == true)
{
  for (int i = pos; i < size - 1; i++)
   listAry[i] = listAry[i + 1];  //Deletes by shifting locations up
  size--;       //Decrease array size by 1
}

cout << "Updated Process List: " << endl;
printList();
}

void processes::retrieveProcess()
{
int retrieveID;

cout << "Please enter the process ID to retrieve (i.e. 24): " << endl;
cin >> retrieveID;

int pos = -1;

for (int i = pos; i < size; i++)
{
  if (retrieveID == listAry[i].id)  //Compare ID to be deleted with rest of list until found
   cout << " ID: " << listAry[i].id << " Name: " << listAry[i].name
   << " Run Time: " << listAry[i].runTime << endl;
}
cout << endl;
}

void processes::printProcessList()
{
printList();
cout << endl;
}

int menu()
{
int response;

cout << " Please select one of the following options: " << endl;
cout << "   (1) Print processes" << endl;
cout << "   (2) Insert a process" << endl;
cout << "   (3) Delete a processes" << endl;
cout << "   (4) Retrieve a processes" << endl;
cout << "   (0) Exit Program" << endl;

cout << " Response: ";
cin >> response;

return response;
}

int main()
{

processes Process;   //Decalre object for a process

int size;
ifstream infile;
int list = -1;    //Deterimines which process list
char answer;
int selection;

cout << "   **Process Program** " << endl;
//Load processes into program

Process.loadList();

do
{
  selection = menu();

  switch (selection)
  {
  case 1: Process.printProcessList();
   break;
  case 2: Process.insertList();
   break;
  case 3: Process.deleteProcess();
   break;
  case 4: Process.retrieveProcess();
   break;
  case 0: exit(0);
   break;
  default:cout << "Invalid. Please choose an option 1-6!" << endl;
  }

  system("pause");

} while (selection != 0);

system("pause");
return 0;
}

CSC 372 Program Assignment 1: Due Date September 20h 11:59 PM Due Date: Tuesday, September 4th 1:29 PM Program Summary Write a C++ object-oriented program to manage a file system for students at Norfolk State University: First Name- string Last Name -string Student ID- unsigned integer Email-string GPA - float The program will manipulate the student list based on students from the file students.dat Class requirements 1. Create a student class or struct based on the student structure 2. Create a students class which contains three private members-an array of students, the size of the array, and a function to print the contents of a process. The processes class will also provide the following functionality a. b. c. d. e. f. g. h. Load data from a data file into a student list Retrieve and print a student from the student list Insert a student into the student list Delete a student from the student list Print the contents of a student record Print the contents for a list of students Sort the student list by last Name Sort the student list by GPA Processing requirements 1. 2. 3. Load the students file students.dat Create a menu to carry out the given operations Implement input validation to avoid erroneous program errors

Explanation / Answer

//Program

#include <fstream>
#include<iostream>
#include <sstream>
#include <bits/stdc++.h>

using namespace std;

class student

{

private:

string FName,LName,Email;

float GPA;

unsigned int StudentID;

public:

void input(string fname, string lastname, string email, float gpa, unsigned int id);

string getFName();

string getLName();

string getEmail();

float getGPA();

int getStudentId();

};

void student::input(string firstname, string lastname, string email, float gpa, unsigned int id)

{

FName = firstname;

LName = lastname;

Email = email;

GPA = gpa;

StudentID = id;

}

string student::getFName(){

return FName;

}

string student::getLName(){

return LName;

}

string student::getEmail(){

return Email;

}

float student::getGPA(){

return GPA;

}

int student::getStudentId(){

return StudentID;

}

class students

{

private:

student std[10];

int n;

public:

void print();

void push(student s,int index);

void setCount(int count);

};

void students::push(student s,int index)

{

std[index]=s;

}

void students::setCount(int count)

{

n=count;

}

void students::print()

{

for(int i=0;i<=n;i++){

cout<<"Details of students";

cout<<"First Name : "<< std[i].getFName();

}

}

int main()

{

string firstname, lastname, email;

float gpa;

unsigned int studentId;

int count = 0;

student s1;

students students1;

cout<<"printing";

std::ifstream file("D:\Data\Students.dat");

std::string str;

while (std::getline(file, str))

{

vector <string> tokens;

stringstream check1(str);

string intermediate;

while(getline(check1, intermediate, ' '))

{

tokens.push_back(intermediate);

}

firstname = tokens[1];

lastname = tokens[2];

stringstream id(tokens[3]);

id >> studentId;

email = tokens[4];

stringstream gp(tokens[5]);

gp >> gpa;

s1.input(firstname,lastname,email,gpa,studentId);

students1.push(s1,count);

count++;

}

students1.setCount(count);

int process;

cout << "1 Insert a student into the student list ";

cout << "2 Print the contents for a list of students ";

cout << "3 Print the contents of a student record ";

cout << "4 Delete a student from the student list ";

cout << "5 Retrieve and print a student from the student list ";

cout << "6 Sort the student list by last Name ";

cout << "7 Sort the student list by GPA";

cin >> process;

switch (process)

{

case 1:

students.insertStudent(student s);

break;

case 2:

students.printListOfStudents();

break;

case 3:

students.printContentStudentRecord();

break;

case 4:

students.deleteStudent(student s);

break;

case 5:

students.printStudentList();

break;

case 6:

students.sortByLNamet();

break;

case 7:

students.sortByGPA();

break;

default:

cout << "Error! option is not correct";

break;

}

}

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