Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I get this error below, seems like I send the terminal the right output but why it's not the same way as it expected? I'm

I get this error below, seems like I send the terminal the right output but why it's not the same way as it expected? I'm not sure if I'm not printing out anything or if its anything else. can I please get help with the code?

image text in transcribed

Here's the assignment and files :- I posted my code so far.

image text in transcribed

image text in transcribedimage text in transcribed

Main.cpp ----------------->

#include

#include

#include "../code_2/fundamentals_2.hpp"

#include

#include

using namespace std;

int main(int argc, char* argv[])

{

// your code here

studentData students[100];

string inputFile = argv[1];

string outputFile = argv[2];

string sortArray[5];

ifstream csvFileIn("students.csv");

csvFileIn.open(argv[1]);

if (!csvFileIn.is_open())

{

cout

}

else

{

int i = 0;

string lines = "";

while (getline(csvFileIn, lines))

{

addStudentData(students, sortArray[0], stoi(sortArray[1]), stoi(sortArray[2]), stoi(sortArray[3]), stoi(sortArray[4]), i);

i++;

}

ofstream csvFileOut("output.csv");

csvFileOut.open(outputFile);

for (int j = 0; j

{

char letterGrade = calcLetterGrade(students[j].average);

if (letterGrade >= * argv[3] && letterGrade

{

csvFileOut

cout

}

}

csvFileOut.close();

}

return 0;

return 0;

}

fundamentals_2.cpp ----------------------->

#include "fundamentals_2.hpp"

char calcLetterGrade(double avg)

{

if (avg >= 90)

{

return 'A';

}

else if (avg = 80)

{

return 'B';

}

else if (avg = 70)

{

return 'C';

}

else if (avg = 60)

{

return 'D';

}

else

{

return 'F';

}

}

void addStudentData(studentData students[], string studentName, int homework, int recitation, int quiz, int exam, int index)

{

students[index].studentName = studentName;

students[index].homework = homework;

students[index].recitation = recitation;

students[index].quiz = quiz;

students[index].exam = exam;

students[index].average = ((homework + recitation + quiz + exam) / 4.00);

}

void printList(const studentData students[], int length)

{

for (int i = 0; i

{

char letterGrade = calcLetterGrade(students[i].average);

cout

}

}

fundamentals_2.hpp ------------------->

#ifndef READFILE2_H__

#define READFILE2_H__

#include

#include

#include

using namespace std;

struct studentData {

string studentName;

int homework;

int recitation;

int quiz;

int exam;

double average;

};

// TODO add detailed explanation on what the function should do

void addStudentData(studentData students[], string studentName, int homework, int recitation, int quiz, int exam, int length);

char calcLetterGrade(double avg);

#endif // READFILE2_H__

Please provide the code.

/home/jovyan/: /tests/test_fundamentals.cpp:263: Failure Expected equality of these values: resp_2_1 Which is: desired_result_2_1 which is: "Tim Thomas, 94.25,A Bob Brown, 84.75,B Jenny Jackson, 77.75, C " With diff: @@ -1,1 +1,3 @@ +Tim Thomas, 94.25, A +Bob Brown, 84.75,B +Jenny Jackson, 77.75, C [ FAILED ] test_fundamentals.TestApp_2 (24 ms) Total Grade is : 0 [------- 5 tests from test_fundamentals (42 ms total) ## Part 2 - Working With an Array-of-Structs **Overview**: In this part of the assignment you will also work with reading in data from an external file. Likewise, your program will write data out to a file, and store data in the program's memory within an array-of-structs data structure. Implement the functions in `code_2\fundamentals_2.cpp with the associated function prototypes located in code_2\fundamentals_2.hpp. The main function is defined in app_2\main_2.cpp'. You are encouraged to use "main_2.cpp to test your functions as you implement them. ### Specifications Your program will accomplish the following: 1. Read a .csv file with 5 columns and up to 10 lines containing information on student grades. 2. Store the information in an array-of-structs. 3. Record the results name, score, and grade out to 'output.csv'. 4. Write a subset of the array to standard output and external file. Create an array that holds the studentData struct objects. Use the following struct declaration: struct studentData { string studentName; int homework; int recitation; int quiz; int exam; double average; }; ### Part 2-A Write a function named .addStudentData": * The addStudentData function has the following declaration: void addStudentData(studentData students[], string studentName, int homework, int recitation, int quiz, int exam, int length); students[l is an array-of-structs of studentData" type "length is the number of items currently stored in the array * Within the function, instantiate a local studentData struct and store the studentName", "homework, 'recitation, quiz', and exam values. * Assume equal weights amongst everything that needs to be graded. Take the average of the homework, recitation, quiz, and exam for each respective student and store it in the struct. * 'student.average = (homework + recitation + quiz + exam) / 4; * Add the struct to the students array. ### Part 2-B Write a function named 'calcLetterGrade: * The `calcLetterGrade function has the following declaration: char calcLetterGrade (double avg); * Write IF-ELSE conditions to assign letter grades based on the following | >=90: AL I--------- 80-89.9: B [70-79.9: CO 60-69.9:D |,,' is >= 'lower_bound" and *

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Business Process Driven Database Design With Oracle PL SQL

Authors: Rajeev Kaula

1st Edition

1795532386, 978-1795532389

More Books

Students also viewed these Databases questions

Question

How wide are Salary Structure Ranges?

Answered: 1 week ago