I have been having trouble with this assignment. Attached will ben the assignment guide lines and my code. Thanks for any help that is offered. My Code: #include // Needed for cin and cout #include // Needed for String variables #include #include // Needed for Input and Output Variables #include // Using namespaces using namespace std; // Constants const string FILL = "=========="; const string RULER = "123456790"; const double AVG = .55; const double MIDTERM = .20; const double FINAL = .25; // Prototype Namespace namespace myNamespace { //enum enum scoreLetter {A, B, C, D, F}; //Function Prototypes double course_grade((homeworkAverage * .55) + (midtermExam * .20) + (finalExam * .25)); myNamespace::scoreLetter score_Letter(int score) { return score >= 90 ? myNamespace::A : score >= 80 ? myNamespace::B : score >= 70 ? myNamespace::C : score >= 60 ? myNamespace::D : myNamespace::F; }; } int main() { // Declare stream variables ifstream inputData; ofstream outputData; // input file stream object std::ifstream file("performance-input.txt"); std::string input; std::vector data; // Declare Variables double homework1, homework2, homework3, homework4, homework5, homework6, homework7, homework8, homework9, homework10; double midtermExam; double finalExam; double present; double absent; double homeworkAverage; double courseGrade; string rulerLine = RULER + RULER + RULER + RULER + RULER + RULER; string fillLine = FILL + FILL + FILL + FILL + FILL + FILL; string firstName; string lastName; // Open input file inputData.open("performance-input.txt"); if (!inputData) { cout << "Cannot open input file." << "Program terminates!" << endl; return 1; } // Open output file outputData.open("performance - input.out"); outputData << fixed << showpoint << setprecision(2); inputData >> midtermExam; inputData >> finalExam; inputData >> present; inputData >> absent; homeworkAverage = (homework1 + homework2 + homework3 + homework4 + homework5 + homework6 + homework7 + homework8 + homework9 + homework10) / 10; courseGrade = (homeworkAverage * .55) + (midtermExam * .20) + (finalExam * .25); while (file >> input) // return file performance-input.txt { cout << left; cout << rulerLine << endl << endl; cout << fillLine << endl; cout << setw(10) << "| Student" << " | " << setw(21) << lastName + ", " + firstName << setw(13) << " | Grade Level" << "| " << setw(10) << "|"; cout << endl; cout << fillLine << endl; cout << setw(10) << "| Present" << " | " << present << setw(18) << " | Absent" << setw(10) << "|" << absent << setw(17) << "|" << endl; cout << fillLine << endl; cout << setw(25) << "| Homework Grades" << " | Average" << setw(19) << " | " << homeworkAverage << setw(12) << "|" << endl; cout << fillLine << endl; cout << setw(25) << "| Homework 1" << " | " << homework1 << setw(19) << "|" << setw(12) << "|" << endl; cout << setw(25) << "| Homework 2" << " | " << homework2 << setw(19) << "|" << setw(12) << "|" << endl; cout << setw(25) << "| Homework 3" << " | " << homework3 << setw(19) << "|" << setw(12) << "|" << endl; cout << setw(25) << "| Homework 4" << " | " << homework4 << setw(19) << "|" << setw(12) << "|" << endl; cout << setw(25) << "| Homework 5" << " | " << homework5 << setw(19) << "|" << setw(12) << "|" << endl; cout << setw(25) << "| Homework 6" << " | " << homework6 << setw(19) << "|" << setw(12) << "|" << endl; cout << setw(25) << "| Homework 7" << " | " << homework7 << setw(19) << "|" << setw(12) << "|" << endl; cout << setw(25) << "| Homework 8" << " | " << homework8 << setw(19) << "|" << setw(12) << "|" << endl; cout << setw(25) << "| Homework 9" << " | " << homework9 << setw(19) << "|" << setw(12) << "|" << endl; cout << setw(25) << "| Homework 10" << " | " << homework10 << setw(19) << "|" << setw(12) << "|" << endl; cout << fillLine << endl; cout << setw(25) << "| Midterm Grade:" << " | " << setw(19) << "|" << midtermExam << "|" << endl; cout << setw(25) << "| Final Exam Grade:" << " | " << setw(19) << "|" << finalExam << "|" << endl; cout << setw(25) << "| Course Grade:" << " | " << setw(19) << "|" << courseGrade << "|" << endl; cout << fillLine << endl; inputData.close(); } int homework[20]; int i; cout << "Read input data into array"; for (i = 0; i < 20; i++) { cin >> homework[i]; } return 0; }
I have been having trouble with this assignment. Attached will ben the assignment guide lines and my code. Thanks for any help that is offered.
My Code:
#include <iostream> // Needed for cin and cout
#include <string> // Needed for String variables
#include <iomanip>
#include <fstream> // Needed for Input and Output Variables
#include <vector>
// Using namespaces
using namespace std;
// Constants
const string FILL = "==========";
const string RULER = "123456790";
const double AVG = .55;
const double MIDTERM = .20;
const double FINAL = .25;
// Prototype Namespace
namespace myNamespace {
//enum
enum scoreLetter {A, B, C, D, F};
//Function Prototypes
double course_grade((homeworkAverage * .55) + (midtermExam * .20) + (finalExam * .25));
myNamespace::scoreLetter score_Letter(int score)
{
return score >= 90 ? myNamespace::A :
score >= 80 ? myNamespace::B :
score >= 70 ? myNamespace::C :
score >= 60 ? myNamespace::D :
myNamespace::F;
};
}
int main()
{
// Declare stream variables
ifstream inputData;
ofstream outputData;
// input file stream object
std::ifstream file("performance-input.txt");
std::string input;
std::vector<std::string> data;
// Declare Variables
double homework1, homework2, homework3, homework4, homework5, homework6, homework7, homework8, homework9, homework10;
double midtermExam;
double finalExam;
double present;
double absent;
double homeworkAverage;
double courseGrade;
string rulerLine = RULER + RULER + RULER + RULER + RULER + RULER;
string fillLine = FILL + FILL + FILL + FILL + FILL + FILL;
string firstName;
string lastName;
// Open input file
inputData.open("performance-input.txt");
if (!inputData)
{
cout << "Cannot open input file."
<< "Program terminates!" << endl;
return 1;
}
// Open output file
outputData.open("performance - input.out");
outputData << fixed << showpoint << setprecision(2);
inputData >> midtermExam;
inputData >> finalExam;
inputData >> present;
inputData >> absent;
homeworkAverage = (homework1 + homework2 + homework3 + homework4 + homework5 + homework6 + homework7 + homework8 + homework9 + homework10) / 10;
courseGrade = (homeworkAverage * .55) + (midtermExam * .20) + (finalExam * .25);
while (file >> input) // return file performance-input.txt
{
cout << left;
cout << rulerLine << endl << endl;
cout << fillLine << endl;
cout << setw(10) << "| Student" << " | " << setw(21) << lastName + ", "
+ firstName << setw(13) << " | Grade Level" << "| " << setw(10) << "|";
cout << endl;
cout << fillLine << endl;
cout << setw(10) << "| Present" << " | " << present << setw(18) << " | Absent" << setw(10) << "|" << absent << setw(17) << "|" << endl;
cout << fillLine << endl;
cout << setw(25) << "| Homework Grades" << " | Average" << setw(19) << " | " << homeworkAverage << setw(12) << "|" << endl;
cout << fillLine << endl;
cout << setw(25) << "| Homework 1" << " | " << homework1 << setw(19) << "|" << setw(12) << "|" << endl;
cout << setw(25) << "| Homework 2" << " | " << homework2 << setw(19) << "|" << setw(12) << "|" << endl;
cout << setw(25) << "| Homework 3" << " | " << homework3 << setw(19) << "|" << setw(12) << "|" << endl;
cout << setw(25) << "| Homework 4" << " | " << homework4 << setw(19) << "|" << setw(12) << "|" << endl;
cout << setw(25) << "| Homework 5" << " | " << homework5 << setw(19) << "|" << setw(12) << "|" << endl;
cout << setw(25) << "| Homework 6" << " | " << homework6 << setw(19) << "|" << setw(12) << "|" << endl;
cout << setw(25) << "| Homework 7" << " | " << homework7 << setw(19) << "|" << setw(12) << "|" << endl;
cout << setw(25) << "| Homework 8" << " | " << homework8 << setw(19) << "|" << setw(12) << "|" << endl;
cout << setw(25) << "| Homework 9" << " | " << homework9 << setw(19) << "|" << setw(12) << "|" << endl;
cout << setw(25) << "| Homework 10" << " | " << homework10 << setw(19) << "|" << setw(12) << "|" << endl;
cout << fillLine << endl;
cout << setw(25) << "| Midterm Grade:" << " | " << setw(19) << "|" << midtermExam << "|" << endl;
cout << setw(25) << "| Final Exam Grade:" << " | " << setw(19) << "|" << finalExam << "|" << endl;
cout << setw(25) << "| Course Grade:" << " | " << setw(19) << "|" << courseGrade << "|" << endl;
cout << fillLine << endl;
inputData.close();
}
int homework[20];
int i;
cout << "Read input data into array";
for (i = 0; i < 20; i++)
{
cin >> homework[i];
}
return 0;
}
![Specifications
• Included is an input file.
Included is a function to aide, if needed
Use the functions, enum, and namespace defined in Assignment 6.
You will need to use a loop to read each student's data
You will need to load every homework grade into an array
Calculate the homework average
The homework average can be calculated while the array is loaded
Move the printing of the report card into a function and pass the variables read.
This includes passing an array of the homework grades
Fields will include: output file, first name, last name, grade level, homework
array, homework average, midterm exam, final exam, present and absence.
This print function should call the other functions from Assignment 6.
Assume the data in the input files is valid data.
Assignment 7 Function(s)
string AssignmentBuild(int a)
{
ostringstream temp;
temp<<a;
return " Assignment
}
+ temp.str();](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2F9a4b07f6-12f9-48ab-bf71-4857b0ee7193%2F41b5f128-a613-441d-b444-8f7b9588c1d8%2Fj3xg8yr_processed.png&w=3840&q=75)
![](/static/compass_v2/shared-icons/check-mark.png)
Step by step
Solved in 2 steps
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)
![Computer Networking: A Top-Down Approach (7th Edi…](https://www.bartleby.com/isbn_cover_images/9780133594140/9780133594140_smallCoverImage.gif)
![Computer Organization and Design MIPS Edition, Fi…](https://www.bartleby.com/isbn_cover_images/9780124077263/9780124077263_smallCoverImage.gif)
![Network+ Guide to Networks (MindTap Course List)](https://www.bartleby.com/isbn_cover_images/9781337569330/9781337569330_smallCoverImage.gif)
![Computer Networking: A Top-Down Approach (7th Edi…](https://www.bartleby.com/isbn_cover_images/9780133594140/9780133594140_smallCoverImage.gif)
![Computer Organization and Design MIPS Edition, Fi…](https://www.bartleby.com/isbn_cover_images/9780124077263/9780124077263_smallCoverImage.gif)
![Network+ Guide to Networks (MindTap Course List)](https://www.bartleby.com/isbn_cover_images/9781337569330/9781337569330_smallCoverImage.gif)
![Concepts of Database Management](https://www.bartleby.com/isbn_cover_images/9781337093422/9781337093422_smallCoverImage.gif)
![Prelude to Programming](https://www.bartleby.com/isbn_cover_images/9780133750423/9780133750423_smallCoverImage.jpg)
![Sc Business Data Communications and Networking, T…](https://www.bartleby.com/isbn_cover_images/9781119368830/9781119368830_smallCoverImage.gif)