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

Are you able to solve this? CSC 372 Program Assignment 1 Program Summar y Write

ID: 3887186 • Letter: A

Question

Are you able to solve this?

CSC 372 Program Assignment 1

Program Summary

Write a C++ object-oriented program to manage an I/O process list and a ready process list for an operating system. The structure of a process is as follows:

Process id – unsigned integer

Process name – string

Process running time – unsigned integer

The program will manipulate these lists based on the process requirements from the file process.dat

Class requirements

1. Create a process class or struct based on the process structure

2. Create a processes class which contains three private members – an array of processes, 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.Load data from a data file into a process list

b.Retrieve and print a process from a process list

c.Create a process and assign it the given values

d.Insert a process into a process list

e.Delete a process from the process list

f.Print the contents of a process

Processing requirements

1.Load the I/O list from the file io.dat

2.Load the Ready list from the file ready.dat

3.Read through the process file and carry out the given operations

Structure of the files

io.dat – process id, process name, process running time

ready.dat – process id, process name, process running time

process.dat – a) operation code, process id, process name, process running time, list (for operation code i[insert])

                          b) operation code, process id, list (for operation codes d[delete], r[retrieve])

                          c) operation code, list (for operation code p[print])

0 represents the i/o list, 1 represents the ready list

Explanation / Answer

#include #include // the class declarations for file stream objects using namespace std; ... int main () { ifstream my_input_file; // an input file stream object ofstream my_output_file; // an output file stream object ...

ifstream my_input_file; // an input file stream object ofstream my_output_file; // an output file stream object my_input_file.open("input_data"); // open the file named "input_data" my_output_file.open("output_data"); // open the file named "output_data" Now the stream my_input_file is connected to the text file on disk named "input_data" and the stream my_output_file is connected to the text file on disk named "output_data". Instead of creating and then opening the file streams in separate statements, you can use a constructor that takes the file name as an argument; after doing the normal initializations, the constructor completes the initialization by opening the named file. The above four statements would then condense down to two: ifstream my_input_file("input_data"); // create and open ofstream my_output_file("output_data"); In both ways of opening a file, you can specify the file path or file name either with a C-string array or literal (as the above examples do), or in C++11 with a std::string. For example: string filename; cin >> filename; ifstream my_input_file(filename); When opening files, especially input files, is it critical to test for whether the open operation succeeded. File stream errors are discussed in more detail below. But for now, here is one way of doing this test using a member function that returns true if the file was successfully opened: if (my_input_file.is_open()) { ! ! // can continue, file opened correctly ! ! } Now that the file streams are open, using them could not be simpler. We can read and write variable values from/to the streams using the stream input and output operators just like with cin and cout. For example, to read an integer and a double from the input file: my_input_file >> int_var >> double_var; To output to the file: my_output_file << "The integer is " << int_var << endl;

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