Lab 12: PAs
- Due No Due Date
- Points 1
- Submitting a file upload
- File Types cpp
Overview
In this lab, work on one of the PAs below or one of the PAs from Lab 11: nCurses. Even if you have already passed 4 (or more) PAs, you are expected to spend lab time working on one of these PAs.
Submitting
Upload whatever you've worked on after 2 hours; it doesn't need to be complete, I just want to see what progress you made during the lab.
PA options
Please see the syllabus and course schedule (both on the homepage) for more information about how many programming assignments you are required to pass, due dates, etc. Of note: you do not need to attempt every or even most PAs.
NOTE: because of Thanksgiving break, you have two-ish weeks starting from Nov. 24 to submit these PAs: they are due for everyone by Dec. 10 at midnight.
PA 12.1 (advanced): Outliers
In analyzing a list of numbers (for instance, heights of people, readings from a sensor, salaries, etc.) it's often interesting to see what the outliers are. An outlier is a value that is extremely different from the rest of the data, and not every data has outliers (so it's more than just the smallest and largest values). There are different ways to determine outliers; one way is to calculate the inter-quartile range (IQR) of the dataset, then compute inner and outer fences. Values that fall inside of the inner fences are not outliers; those that fall between the inner and outer fences are minor outliers; those that fall outside of the outer fences are major outliers. See this page for the steps involved Links to an external site..
Your program should assume that the values are real numbers (floating points) and are listed in order. Your program should prompt the user for the name of the data file, read it in, and compute the fences. It should display the outliers as well as the upper and lower inner and outer fences, Q1, Q2, and Q3. Arrange the outliers and the statics in an orderly fashion. For example, here's what a run of the program might look like:
$ ./pa12-1
Enter data file name: pa12-1-input.txt
36.295
35.4
--Upper outer fence (33.7)--
28.3
--Upper inner fence (26.5)--
--Q3 (19.3)--
--Q2 (16.31)--
--Q1 (14.5)--
--Lower inner fence (7.3)--
5.18
--Lower outer fence (0.1)--
0.01
0.005
0.002
Note that none of the non-outliers are shown. You should define separate functions to:
- read the data in
- compute the stats (inner and outer fences, Q1, Q2, Q3, IQR)
- display the outliers and stats
Feel free to define other functions as necessary. I recommend that you use a struct named Stats that includes a data member for each of the stats we care about (i.e., the ones listed above). This will make it easier to pass between functions.
Here are the specs (make sure to copy and paste these at the top of your source code; fill out your name, date, etc. and place an 'x' in each of the boxes; if any of the boxes aren't checked, then it's not ready to submit!).
// Name:
// Date:
// Partner:
//
// Specifications checklist for PA Option 12.1 (Advanced)
// [ ] the header includes your name and anyone you worked with
// [ ] the header includes this specifications checklist
// [ ] the code in indented properly (use the autoformatter if you're not sure)
// [ ] useful comments are present above chunks of code that "hang together" (work toward a higher level goal)
// [ ] the identifiers are well named
// [ ] the program compiles
// [ ] the program runs without crashing or hanging
// [ ] all output and prompts look clean (correct spelling, capitalization, nothing squished)
// [ ] all prompts specify the required format of the input and work as expected
// [ ] the user is prompted for the name of the file to read in
// [ ] the program correctly computes the stats of the read in data set
// [ ] Q1, Q2, Q3, IQR
// [ ] upper and lower inner and outer fences
// [ ] all variables, struct names, and functions are named correctly (variables start with
// lowercase letters, struct names start with an uppercase letter; function names either all
// start with an uppercase or all start with a lower case letter)
// [ ] the output
// [ ] at least three functions are defined and used
// [ ] reading the data
// [ ] computing the stats
// [ ] displaying the outliers
// [ ] the input file is closed when reading is finished
PA 12.2: Area under the curve (PA 2.1) with batch mode
In PA 2.1: Area under the curve, you were tasked with estimating the area under a simple 2-degree polynomial within a certain x interval. In this updated version, you will add support for batch mode. That is, the program should prompt the user for the name of a file that include a separate polynomial and interval on each line.
For example, a line may look like this:
-1 2 0.5 1 1.5
Where -1, 2, and 0.5 are the coefficients a, b, and c in the polynomial a + bx + cx2, and 1 and 1.5 mark the interval over which the area should be computed.
For each line in the input file, compute the estimated area and output the result to a new file (also provided by the user). The output should look just like the input, but should include the estimated area after the last number of the input. E.g., for the input line above, we should get:
-1 2 0.5 1 1.5 1.14699
since 1.14699 is the estimated area.
Here are the specs (make sure to copy and paste these at the top of your source code; fill out your name, date, etc. and place an 'x' in each of the boxes; if any of the boxes aren't checked, then it's not ready to submit!).
// Name:
// Date:
// Partner:
//
// Specifications checklist for PA Option 12.2
// [ ] the header includes your name and anyone you worked with
// [ ] the header includes this specifications checklist
// [ ] the code in indented properly (use the autoformatter if you're not sure)
// [ ] identifiers are well named
// [ ] the program compiles
// [ ] the program runs without crashing or hanging
// [ ] all output and prompts look clean (correct spelling, capitalization, nothing squished)
// [ ] all prompts specify the required format of the input and work as expected
// [ ] the user is prompted for the name of an input and output file
// [ ] the program prompts reads in a file formatted as: a b c x1 x2, where a, b, and c are
// coefficients in the polynomial y = a + bx + cx^2 under which to approximate the area
// and x1 and x2 are the start and end of the interval of x to calculate the area between
// [ ] for each line in the input file, the program...
// [ ] approximates the area under the polynomial within the given interval using
// three trapezoids, each a non-overlapping third of the interval
// [ ] outputs the original parameters (a b c x1 x2) and the approximate area to a new line
// in the output file
// [ ] the program is accurate -- the program's approximations match the expect results (see PA2.1)
// [ ] files are all closed when finished reading or writing
PA 12.3 (Advanced): Word stats with files
This is an extension of PA 6.1 Word Stats (though you can also start from PA7.1, which is the same, but with functions, or PA9.3, which is the same but also uses structs instead of parallel vectors). Rather than having the user enter the text that is processed, this updated version should prompt the user for the name of a file. The program should then calculate stats over the words in that file. That means there's no longer a need for the sentinel "END".
Here are the specs (make sure to copy and paste these at the top of your source code; fill out your name, date, etc. and place an 'x' in each of the boxes; if any of the boxes aren't checked, then it's not ready to submit!).
// Name:
// Date:
// Partner:
//
// Specifications checklist for PA Option 12.3 (Advanced)
// [ ] the header includes your name and anyone you worked with
// [ ] the header includes this specifications checklist
// [ ] the code in indented properly (use the autoformatter if you're not sure)
// [ ] useful comments are present above chunks of code that "hang together" (work toward a higher level goal)
// [ ] the identifiers are well named
// [ ] the program compiles
// [ ] the program runs without crashing or hanging
// [ ] all output and prompts look clean (correct spelling, capitalization, nothing squished)
// [ ] the program prompts the user for the name of an input file
// [ ] the input file is read in and all words contained within are processed
// [ ] the program uses parallel (multiple) arrays or vectors to store words and their counts OR
// a vector of struct instances (see PA 9.3)
// [ ] words are stored and reported at the end in all lower case
// [ ] these stats are displayed at the end and are accurate:
// [ ] the number of total words entered
// [ ] the number of distinct words (case insensitive)
// [ ] the number of characters (the length of all input words summed together)
// [ ] the distribution of distinct words and their corresponding counts represented as a bar graph
// [ ] the left side of the bar graphs are aligned across words
Submissions
Submit your PA to First programming assignment, Second programming assignment, Third programming assignment, Fourth programming assignment, or Fifth programming assignment based on whether this is your first, second, etc. PA. If you are working with a partner, both of you must submit individually.
Rubric
Criteria | Ratings | ||
---|---|---|---|
Worked diligently on the lab problems
|
|
||
Submitted all materials according to the instructions
|
|
||
|