Starting from:
$30

$24

HOMEWORK 1 Solution




I have a large amount of text data with student scores stored as series of integers and floating 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 file:




{




"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




}







I have provided you a basic test app which you can use to ensure that your code is somewhat passing. I do not test the individual values of “id” and “grade”, but I will in my full tester. This means that, while you could only print the “max id” and “max score” to pass the provided tester, you will not pass my full tester.






If you are having problems getting valid JSON, copy the output from your program and try a JSON validator such as: https://jsonformatter.curiousconcept.com/






I have provided you source for parse scores app and a make file. In addition, I have given you a python script to test your app. You should definitely read the makefile and I would encourage you to read the python. It is simple code and an easy intro to python.







Late assignments will lose 25% per day late, with no assignment begin accepted after 4 days (100% re-duction in points).




Check your syllabus for the breakdown of grading.

More products