Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

*Do Not Use A Header File* I have a large amount of text data with student scores stored as series of integers and oating point

*Do Not Use A Header File*

I have a large amount of text data with student scores stored as series of integers and oating point values. I would like to read that data in JSON format.

Given the format: number of students, student id, number of grades, grade 0, grade 1, grade n

Read in each of the number of students students and write their id and number of grades grades to the standard output stream as indicated in the provided source code. The application should perform as follows: The program is called and and is run with no prompt for input: ./parse source The program reads from the standard input stream a series of characters in the indicated format e.g. 2 1234 3 98.7 87.92 77.32 2345 3 93.1 90.23 81.21 and parses the values as indicated in the given source le: { "students" : [ { "id" : 1234, "grades" : [ 98.7, 87.92, 77.32 ] }, { "id" : 2345, "grades" : [ 93.1, 90.23, 81.21 ] } ], "max_id" : 1234, "max_score" : 98.7 }

My code:

#include using std::cin; using std::cout; using std::endl;

int main(int argc, char* argv[]) { /* The following input * * 2 1234 3 98.7 87.92 77.32 2345 3 93.1 90.23 81.21 * * would result in the following output. */ while(1){ switch(students){ case id: break; case grades: break; default: std::cout << "default "; // no error break; } cout << "{" << endl; cout << " \"students\" : [" << endl; cout << " { \"id\" : 1234, \"grades\" : [ 98.7, 87.92, 77.32 ] }," << endl; cout << " { \"id\" : 2345, \"grades\" : [ 93.1, 90.23, 81.21 ] }" << endl; cout << " ]," << endl; cout << " \"max_id\" : 1234," << endl; cout << " \"max_score\" : 98.7" << endl; cout << "}"; } }

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

Main Memory Database Systems

Authors: Frans Faerber, Alfons Kemper, Per-Åke Alfons

1st Edition

1680833243, 978-1680833249

More Books

Students also viewed these Databases questions