From 19816403d3b1b1a3bff547937b2ffa467ce74a8b Mon Sep 17 00:00:00 2001 From: Jidong Xiao Date: Sun, 7 Jan 2024 23:51:42 -0500 Subject: [PATCH] adding cp3 --- labs/01_getting_started/README.md | 15 +++++++-------- labs/01_getting_started/sample_output.txt | 15 +++++++++++++++ labs/01_getting_started/users.json | 15 +++++++++++++++ 3 files changed, 37 insertions(+), 8 deletions(-) create mode 100644 labs/01_getting_started/sample_output.txt create mode 100644 labs/01_getting_started/users.json diff --git a/labs/01_getting_started/README.md b/labs/01_getting_started/README.md index a173aff..a4966cd 100644 --- a/labs/01_getting_started/README.md +++ b/labs/01_getting_started/README.md @@ -102,7 +102,7 @@ Now let's write a brand new C++ program to learn about command line arguments. First open up a brand new file named `silly.cpp`. Include <iostream> at the top of the file. -Read this [Programming Information](https://www.cs.rpi.edu/academics/courses/fall23/csci1200/programming_information.php) explaining command line arguments in C++. You may also want to refer to 1.13 of the lecture notes for array syntax. +Read this [Programming Information](https://www.cs.rpi.edu/academics/courses/fall23/csci1200/programming_information.php) explaining command line arguments in C++. You may also want to refer to the lecture notes for array syntax. - To start, let's write a program that expects only integers on the command line, and it will print the product (multiplication) of those @@ -138,16 +138,15 @@ product of integers: -600 ### To complete Checkpoint 2: Show a TA or mentor your program. Be ready to demonstrate that your program works with other input requested by the TA or mentor. -## Checkpoint 3 +## Checkpoint 3: File IO *estimate: 45 minutes* -For the remainder of the lab time, work on the Crash Course in C++ -Exercises. Discuss the exercises with your lab study group classmates and ask -your TA and mentors lots of questions! +In lecture we talked about how to use the STL file stream library fstream to read data from a file and/or write the output to a file. Let's do some exercises. -### To complete Checkpoint 3 (and the entire lab): -About 10 minutes before the end of lab the TA and mentors will make a final visit to each study group and check you off. Please be ready to quickly update them -on your progress. +Write a C++ program which reads this [json file](users.json), and print all user names into an output file called output.txt. Your output file must be the same as this [sample output file](sample_output.txt). + +### To complete Checkpoint 3: +Show a TA or mentor your program. Your program must produce the right output and you must be able to explain your program. ## SPECIAL NOTE FOR FIRST WEEK OF CLASSES diff --git a/labs/01_getting_started/sample_output.txt b/labs/01_getting_started/sample_output.txt new file mode 100644 index 0000000..eda9bb3 --- /dev/null +++ b/labs/01_getting_started/sample_output.txt @@ -0,0 +1,15 @@ +taylorswift +jenniferaniston +nbcsnl +easymoneysniper +agt +justinbieber +jaytatum0 +andrewyang +nicolekidman +chelseafc +lakers +carrieunderwood +cnn +cmpulisic +andersoncooper diff --git a/labs/01_getting_started/users.json b/labs/01_getting_started/users.json new file mode 100644 index 0000000..ab25f14 --- /dev/null +++ b/labs/01_getting_started/users.json @@ -0,0 +1,15 @@ +{"id": "11830955", "username": "taylorswift", "url": "https://www.instagram.com/taylorswift", "fullName": "Taylor Swift", "biography": "Iโ€™m the problem, itโ€™s me", "notifications": [{"pauseAll": "false", "likes": "true", "tags": "true", "comments": "true", "newFollowers": "true", "messageRequests": "true"}]} +{"id": "21388754496", "username": "jenniferaniston", "url": "https://www.instagram.com/jenniferaniston", "fullName": "Jennifer Aniston", "biography": "My friends call me Jen.\nFounder, @lolavie.", "notifications": [{"pauseAll": "false", "likes": "true", "tags": "true", "comments": "true", "newFollowers": "true", "messageRequests": "true"}]} +{"id": "218738123", "username": "nbcsnl", "url": "https://www.instagram.com/nbcsnl", "fullName": "Saturday Night Live", "biography": "The official Instagram of Saturday Night Live.\nWatch on @nbc and @peacock. Streaming next day on Peacock.", "notifications": [{"pauseAll": "false", "likes": "true", "tags": "true", "comments": "true", "newFollowers": "false", "messageRequests": "false"}]} +{"id": "13864937", "username": "easymoneysniper", "url": "https://www.instagram.com/easymoneysniper", "fullName": "", "biography": "", "notifications": [{"pauseAll": "false", "likes": "false", "tags": "false", "comments": "false", "newFollowers": "false", "messageRequests": "false"}]} +{"id": "255788740", "username": "agt", "url": "https://www.instagram.com/agt", "fullName": "America's Got Talent - AGT", "biography": "Two minutes can change your life. #AGT: Fantasy League premieres Monday, January 1 on @nbc and streaming on @peacock.", "notifications": [{"pauseAll": "true", "likes": "true", "tags": "true", "comments": "true", "newFollowers": "true", "messageRequests": "true"}]} +{"id": "6860189", "username": "justinbieber", "url": "https://www.instagram.com/justinbieber", "fullName": "Justin Bieber", "biography": "JUSTICE the album out now\n@drewhouse", "notifications": [{"pauseAll": "false", "likes": "false", "tags": "true", "comments": "true", "newFollowers": "true", "messageRequests": "true"}]} +{"id": "41157727", "username": "jaytatum0", "url": "https://www.instagram.com/jaytatum0", "fullName": "Jayson Tatum๐Ÿ™๐Ÿ€", "biography": "In Jesus Name I Play ๐Ÿ™\nOh yeah I'm from the LOU\n@enjoysmallwins", "notifications": [{"pauseAll": "false", "likes": "true", "tags": "false", "comments": "false", "newFollowers": "true", "messageRequests": "true"}]} +{"id": "3969496290", "username": "andrewyang", "url": "https://www.instagram.com/andrewyang", "fullName": "Andrew Yang", "biography": "Entrepreneur, Dad, Champion of a Human-Centered Economy, <202a>#YangGang<202c>, <202a>#Forwardist<202c>, UBI, Founder of Forward Party, NYT bestselling author", "notifications": [{"pauseAll": "false", "likes": "false", "tags": "true", "comments": "true", "newFollowers": "true", "messageRequests": "false"}]} +{"id": "1637269350", "username": "nicolekidman", "url": "https://www.instagram.com/nicolekidman", "fullName": "Nicole Kidman", "biography": "@BlossomFilms", "notifications": [{"pauseAll": "false", "likes": "true", "tags": "true", "comments": "true", "newFollowers": "false", "messageRequests": "false"}]} +{"id": "244309106", "username": "chelseafc", "url": "https://www.instagram.com/chelseafc", "fullName": "Chelsea FC", "biography": "", "notifications": [{"pauseAll": "false", "likes": "true", "tags": "true", "comments": "true", "newFollowers": "true", "messageRequests": "false"}]} +{"id": "16917874", "username": "lakers", "url": "https://www.instagram.com/lakers", "fullName": "Los Angeles Lakers", "biography": "Welcome to the #LakeShow\n๐Ÿ† 17x Champions\nWant more? @LakersScene & @loslakers", "notifications": [{"pauseAll": "false", "likes": "true", "tags": "true", "comments": "false", "newFollowers": "false", "messageRequests": "true"}]} +{"id": "306227985", "username": "carrieunderwood", "url": "https://www.instagram.com/carrieunderwood", "fullName": "Carrie Underwood", "biography": "Official Carrie Underwood Instagram", "notifications": [{"pauseAll": "false", "likes": "false", "tags": "false", "comments": "true", "newFollowers": "true", "messageRequests": "true"}]} +{"id": "217723373", "username": "cnn", "url": "https://www.instagram.com/cnn", "fullName": "CNN", "biography": "Asking the hard questions and bringing unique perspective from across the globe. This is CNN.", "notifications": [{"pauseAll": "false", "likes": "true", "tags": "false", "comments": "true", "newFollowers": "false", "messageRequests": "true"}]} +{"id": "292388190", "username": "cmpulisic", "url": "https://www.instagram.com/cmpulisic", "fullName": "Christian Pulisic", "biography": "USA & AC Milan ๐Ÿ‡บ ๐Ÿ‡ธ โšฝ๏ธ", "notifications": [{"pauseAll": "false", "likes": "true", "tags": "false", "comments": "false", "newFollowers": "false", "messageRequests": "true"}]} +{"id": "3071167", "username": "andersoncooper", "url": "https://www.instagram.com/andersoncooper", "fullName": "Anderson Cooper", "biography": "Season 2 of ALL THERE IS, my podcast about grief and loss, starts November 29th.", "notifications": [{"pauseAll": "true", "likes": "false", "tags": "true", "comments": "true", "newFollowers": "true", "messageRequests": "true"}]}