Hi, I have an assignment that I need completed. Please read the attached document. Thank you!
Criteria Ratings Points
Program
Meets the
Assignment
Requirements
32 to >28.0 pts
Advanced
Program meets all of the
assignment requirements.
28 to >21.0 pts
Proficient
Program meets at least 50%
but less than 90% of the
assignment requirements.
21 to >0.0 pts
Developing
Program meets
less than 50% of
the assignment
requirements.
0 pts
Not
Present
32 pts
Program
compiles and
executes
without
crashing
10 to >8.0 pts
Advanced
Program compiles and
executes without errors.
8 to >6.0 pts
Proficient
Program compiles but
encounters an endless loop,
“hangs”, or throws an
exception.
6 to >0.0 pts
Developing
Program does not
compile
0 pts
Not
Present
10 pts
Screen shots 3 to >2.0 pts
Advanced
Complete set of screen shots
are submitted and are
submitted within the Microsoft
Word document(s), with the 4
integrity assertions included
2 to >1.0 pts
Proficient
Screen shots are submitted
but are either incomplete or
are not submitted within the
Microsoft Word document(s),
or the Microsoft Word
document(s) does/do not
include the 4 required
assertions of integrity.
1 to >0.0 pts
Developing
Screen shots are
submitted but are
either incomplete
or are not
submitted within
the Microsoft
Word
document(s), and
the Microsoft
Word
document(s)
does/do not
include the 4
required
assertions of
integrity.
0 pts
Not
Present
3 pts
C++ Programming Grading Rubric | CSIS112_B01_202230
Criteria Ratings Points
Program
Internal
Documentation
3 to >2.0 pts
Advanced
Internal comments are
sufficient in all files within the
program to describe the
program’s logic, the meaning
of the variables, and the
overall purpose of each file,
function, and class. The
program contains a comment
at the top of the driver file that
indicates the student’s name,
assignment number, and a
brief description of the
purpose of the program.
2 to >1.0 pts
Proficient
Internal comments are
present, but they are not
sufficient to describe the
logic of the program, the
meaning of the variables, or
the overall purpose of each
file, function, and class; OR
The program does not
contain a comment at the
top of the driver file that
indicates the student’s
name, assignment number,
and a brief description of the
purpose of the program.
1 to >0.0 pts
Developing
Comments in the
code are minimal
and do not
contain the
student’s name,
assignment
number, and
description of the
purpose of the
program.
0 pts
Not
Present
3 pts
Style of code 12 to >10.0 pts
Advanced
Program is modular. It
contains no global variables
unless they are constants.
Adheres to the principles of
minimalization and least
privilege: Constants are used
where appropriate; variables
are declared with the proper
level of access (for classes
only); only variables that are
needed are created; and
program uses the correct data
structure (array, vector, etc.)
for the assignment.
10 to >8.0 pts
Proficient
Program is minimally
modular. At most one global
variable is declared; at most
one variable is declared with
the incorrect level of access;
at most one variable is
declared which should not
be used; or the program
uses an incorrect data
structure for the assignment.
8 to >0.0 pts
Developing
Program is not
modular (i.e.
everything is
contained within
main()); multiple
global variables
are used; more
than one variable
is declared which
should not be
present; or the
program uses an
incorrect data
structure for the
assignment.
0 pts
Not
Present
12 pts
Total Points: 60
C++ Programming Grading Rubric | CSIS112_B01_202230
C++ Programming: Vectors and Sorting Assignment Instructions
Overview
This assignment utilizes a class in an application that might be useful in the “real world.” It requires the sorting of, and computation with, data stored in a vector inside of a class. In this assignment, you will design an Object-Oriented program and manipulate data using a vector within the class.
Instructions
You are working for a university to maintain a list of grades and some related statistics for a student.
Class and Data members:
Create a
class
called
Student
that stores a student’s grades (integers) in a
vector
(do not use an array). The class should have data members that store a student’s name and course for which the grades are earned.
Constructor(s):
The class should have a
2-argument constructor
that receives the student’s name and course as parameters and sets the appropriate data members to these values.
Member Functions:
The class should have functions as follows:
1. Member functions to set and get the student’s name and course variables.
2. A member function that adds a single grade to the vector. Only positive grades are allowed. Call this function
AddGrade
.
3. A member function to
sort
the vector in ascending order.
Feel free to use the sort function that is available in the algorithm library for sorting vectors. Here is a web page that may help:
https://www.tutorialspoint.com/sorting-a-vector-in-cplusplus
Or, if you would prefer to write your own sort code, you may find this site to be helpful:
http://www.cplusplus.com/articles/NhA0RXSz/
4. A member function to compute the average (x̄) of the grades in the vector. The formula for calculating an average is
x̄ = ∑xi / n
where xi is the value of each grade and
n is the total number of grades in the vector.
When using a vector, you can manipulate it just like an array. For a review on how to loop over an array to calculate a sum, you may find this video to be helpful:
5. A member function to determine the lowest grade in the vector and a separate member function to determine the highest grade in the vector. [Note that to receive credit for these functions, they
must contain an algorithm
to search through the vector to determine the minimum or maximum value. You cannot simply sort the vector and return the first or last data member or use the *min_element or *max_element functions.]
Hint: The following web page provides an excellent example of algorithms to find the min and max values in an array: [Look at Technique 2]
https://www.studymite.com/cpp/examples/finding-maximum-and-minimum-number-in-array-in-cpp/
6. A member function (e.g. getNumGrades) to return the number of grades that are stored in the vector. Remember that a vector knows its own size. Therefore, you
don’t
need to keep track of the number of items stored in a vector in a separate data member in the class. You also don’t want to make your vector public – it should be private. Therefore, you can create a public getNumGrades function that will simply return the size of the vector.
7. A member function to display the student’s name, course, and vector of sorted grades.
Write a program (client) that uses the class by creating a Student object
and prompting the user for a file name
. Appropriate error checking is required to ensure that the file exists and can be opened successfully. Also,
the name of the file may contain a space
; therefore, be sure to use getline instead of cin when you prompt the user to enter the name of the file.
The client should read in the file contents and store them in the object. The file will be formatted such that the first line contains the student’s name, the second line contains the course name, and each successive line contains a grade. A typical input file might contain:
John Smith
CSIS 112
90
85
97
91
87
86
88
82
83
Note that the file may contain any number of grades for a given course. Therefore, you need to read in and store each grade until you reach the end of the file.
The client (i.e. main()) should read in the contents of the file. After
each
grade is read in, it should call the
addGrade
member function in the Student class to add
the new grade
(i.e. one grade at a time) to the vector. [
Do not
create a vector in main and pass the entire vector in to the
addGrade
function in the Student class. Pass in only one grade at a time and allow the
addGrade
function to add it to the vector of grades in the class.]
Main() should then produce a report that displays the student’s name and course, the total number of grades in the file, the lowest grade, the highest grade, the average of all the grades, and finally, a listing of all of the grades that were read in. The listing of all of the grades must be displayed in sorted order (ascending – from lowest to highest).
All output should be labeled appropriately, and validity checking should be done on input of the filename and also the grades that are read in.
If a non-numeric or negative value is encountered in the file when reading in the grades, the program should output an error message indicating that a non-numeric or negative value was found in the file,
and the entire program should then terminate.
If a non-numeric or negative value is found, consider the entire file to be corrupted and don’t try to produce any calculations nor display the contents of the vector – just end the program with an appropriate error message. [Make sure the error message is displayed long enough for the user to read it before ending the program. – you may use the
system(“pause”)
command for this. Note that there are several security and performance issues with using
system
commands, and you’ll learn more about these later, but for now, feel free to use the
system(“pause”)
command. ]
The executing program should look something like this:
In the screen above, notice that the average of the grades is displayed with decimal points. Whenever you are calculating a statistic like an average,
never
truncate the decimal portion unless you are told to do so. Imagine if the average of your grades in this class is 89.9… You definitely do
not
want your final grade truncated to 89. Therefore, in this assignment, do
not
truncate the decimal portion of the average you calculate. Remember the rules of integer division. That is, an int divided by an int is an int. Therefore, make sure to convert the numerator or denominator to a double before performing the division.
If a negative grade is read in, the program should look something like this:
If a non-numeric grade is read in, the program should look something like this:
In the screens above, notice that the program pauses long enough to read the error message and no statistics nor grades are displayed. This is accomplished through the use of the system(“pause”) command.
Additional information: File manipulations
Files were covered in your introduction to C++ programming class. However, you may not have had much experience manipulating them. To assist you in the file aspects of this program, you can view these short videos:
Working with Files
Tips for File Handling
Writing Custom File Structures
Reading Custom File Structures
Cool Program Working with Files
Finishing the Awesome Program
Reviewing the Final Program
More Additional Information: Error checking data in files
Recall from your first programming assignment that you were given the code to check for a non-numeric or negative value entered by the user. Now you are being asked to validate the data that is read in from a file.
In general, a file object behaves in the same way as
cin
. That is, it goes into the fail state when a non-numeric is entered. Additionally, the file object has another function called
eof
(stands for “end of file”) that indicates when the last data item has been read in.
The difference between a file object’s
fail
function and the
eof
function is subtle. When the last data item is read in from a file, the
eof
function returns TRUE. That is, you have reached the end of the file. However, the
fail
function is still FALSE at this point (that is, the file object is not yet in the fail state). However, once the program tries to read past the end of the file, the
fail
function then returns TRUE (i.e. the file object goes into the fail state). Keep this in mind as you look at the example code below.
You may also notice in the code below that I haven’t cleared the file object out of the fail state. Again, the file object behaves just like
cin
. As long as the file object is in the fail state, it can’t read in any new values. In your current assignment, you don’t need to clear it out of the fail state because once an invalid value is encountered in a file, you want your program to exit—not read in more values. However, if you ever want your program to continue reading from a file even after finding an invalid value in it, you need to clear the file object out of the fail state in the same way that you cleared cin out of the fail state in your first assignment using the
clear
function: infile.clear().
Example code: (feel free to use this in your program and modify as needed)
Assume you have the following code that reads in data from a file called “integers.txt”. Each data item is supposed to be an integer.
· If the program encounters a non-numeric value, the program displays an error message and immediately ends.
· If the program encounters a negative value, the program displays an error message and immediately ends.
· If the file was empty from the beginning, the “End of file reached” message is displayed and the program ends.
· If the data item read in is good (i.e. numeric and positive), it prints out the number.
· When the last data item is read in, the program prints out the “End of file reached” message.
#include
#include
using namespace std;
int main()
{
ifstream infile; //instantiate a file object
int num{ 0 }; //variable to hold the number read in; initialized to 0
infile.open(“integers.txt”); //try to open the file
//An error check should go here to ensure that the file opened successfully. You should be able to figure this out by watching the video links above.
/*The following is a loop to read in all of the values in the file.
This loop executes for as long as the file object has not gone into the fail
state (caused by reading past the end of the file or reading in a non-numeric value) and as long as the last number read in is positive. Otherwise, the loop
ends, and the program ends.*/
while (!infile.fail() && num >= 0)
{
infile >> num; //read in a value from the file
/*If the file object goes into the fail state, BUT the eof has not been
reached, then the problem is due to reading a non-numeric value into
a variable designed to hold a numeric value. */
if (infile.fail() && !infile.eof())
{
cout << "A non-numeric value was found in the file...Exiting program. " << endl;
}
/*If the file object goes into the fail state, and the eof has been reached, the file object is in the fail state because the program has read past the end of the file. This can occur if the file is empty. If the file is empty and you try to read in anything, the file object immediately goes into the fail state, and the eof function returns TRUE. */
else if (infile.fail() && infile.eof())
{
cout << "End of file reached." << endl;
}
//If the number is negative...
else if (num < 0)
{
cout << "A negative value was found in the file...Exiting program. " << endl;
}
//Otherwise, do something with the value read in, such as print it out.
else
{
cout << "The number read in was " << num << endl;
}
} //end of while loop
system("pause");
return 0;
}
I encourage you to paste the code above into a C++ program and play around with it. It will help you in this assignment as well as future ones to really understand file manipulations. You can play around with various values in your textfile to witness the behavior.
I recommend using these possible test cases for the integers.txt file:
Empty file
Leave the file completely empty
File with a letter at the beginning
A
2
3
4
5
File with a letter at the end
1
2
3
4
A
File with a letter in the middle
1
2
A
4
5
File with a negative number at the beginning
-1
2
3
4
5
File with a negative number at the end
1
2
3
4
-5
File with a negative number in the middle
1
2
-3
4
5
File with no negative numbers and no letters
1
2
3
4
5
By the way, please notice how many comments I put in the code above. This is how you should document your programs to receive full credit on your assignments. Documentation is essential to help other programmers decipher your code and to understand your logic.
Creating test cases like I illustrate above is also vital in industry. You always want to check your extremes (beginning and ending values) as well as values within the middle of a range. You should also test every possible scenario to avoid unexpected results (e.g. negatives, non-numerics, etc.).
Use good coding style [modular (use functions where appropriate), separate .h and .cpp class files, no globals, meaningful comments, etc.] throughout your program. Finally, make sure that you do not misspell anything in your output or prompts to the user. Users easily lose confidence in a system when they see misspelled words or grammatical errors. In short, make your program as professional as possible.
Deliverables
:
· Complete the programming assignment described above and submit your completed assignment in accordance with the assignment submission policies.
To give you an idea of the general criteria that will be used for grading, here is a checklist that you might find helpful:
Compiles and Executes without crashing
Word document contains screen shots and integrity statements
Appropriate internal documentation
Style:
No global variables
Code is modular
File is closed after use
Appropriate Pre-processing and using directives
Member functions and variables are declared with appropriate
protection (i.e. private or public)
Three separate files are created for the program: Student.h (header file), Student.cpp (class implementation file), and StudentDriver.cpp (driver file)
Requirements:
Class Creation
Appropriate data members are declared
Two argument constructor initializes data members
Set and get functions for data members
Get function for total number of grades
addGrade() -- adds a single grade to the vector
sortGrades() - sorts vector in ascending order
averageGrades() - produces correct average
findMinGrade() and findMaxGrade()
displayStudentInfo()
Inputs
Prompts user for file name
Appropriate error checking is in place to ensure that the file exists
Student name, Course, and Grades are correctly read in from the file and stored in the Student object
Error checking is performed on input data: It outputs appropriate error message; does not close the program until the error message can be read; indicates the problem with the invalid item.
Processing and Outputs
Student object created correctly
Ouput consists of the number of grades read in, the student name and course, the sorted vector of grades, the average of the grades, and the low and high grades for the student for the course – all formatted appropriately
Page 2 of 2
Why Choose Us
- 100% non-plagiarized Papers
- 24/7 /365 Service Available
- Affordable Prices
- Any Paper, Urgency, and Subject
- Will complete your papers in 6 hours
- On-time Delivery
- Money-back and Privacy guarantees
- Unlimited Amendments upon request
- Satisfaction guarantee
How it Works
- Click on the “Place Order” tab at the top menu or “Order Now” icon at the bottom and a new page will appear with an order form to be filled.
- Fill in your paper’s requirements in the "PAPER DETAILS" section.
- Fill in your paper’s academic level, deadline, and the required number of pages from the drop-down menus.
- Click “CREATE ACCOUNT & SIGN IN” to enter your registration details and get an account with us for record-keeping and then, click on “PROCEED TO CHECKOUT” at the bottom of the page.
- From there, the payment sections will show, follow the guided payment process and your order will be available for our writing team to work on it.