ENGR 021 Fall 2014 Assignment #4
DUE: Monday, October 27, 2014 6:30 PM at Start of Class
1. Data Histogram: Write a C++ program that takes in a set of 25 or more exam scores (positive integers between 0 and 100). It then prints out an asterisk histogram distribution of the scores segregated in levels of ten (0-9, 10-19, 20-29, 30-39, etc.). Give the user the opportunity to input additional sets of scores if they would like to. Here's a sample session: Enter scores separated by a space: 84 73 94 53 55 85 42 34 67 86 74 73 89 96 77 79 21 70 48 75 64 11 89 94 61 Here is the distribution for the 25 scores that you entered: 00-09| 10-19| * 20-29| * 30-39| * 40-49| ** 50-59| ** 60-69| *** 70-79| ******* 80-89| ***** 90-99| *** 100| Would you like to enter another distribution (y/n)? n Turn in histograms for at least 6 score sets. If you get tired of making up scores, you may use the built in function rand() to feed you integers, either as part of this program or as a helper program written separately. For example, to get a random integer between 1 and 100, #include cstdlib, and: random_score=rand()%100 + 1 //this creates one random integer score between 1-100
As discussed in class, there are many formulas for computing pi, which include methods that sum one or more infinite series of terms. An additional way could use the simple formula for the area of a circle, which unlike other shapes, has pi in its area formula. Thus we can calculate the area of a full circle, half circle, or quarter circle with small shapes of known areas, by filling it in and adding them up. By setting radius = 1 for our reference circle, its area will equal pi since 1 squared times pi is pi! You can choose triangles, rectangles, or any other shapes who's areas don't include pi - as long as it fills up the circular shape. Whatever shapes you chose to fill up the circle, show a table of results for 10, 100, and 1000 iterations of successively smaller shapes We will begin to develop a formula and the algorithm in class - you complete it and document it in the report that you turn in with your program. All steps in your solution will need to be extensively and carefully documented in pseudocode, which may be up to a page long.
Let's construct a small database of a home video collection (or your friend's, family's, etc. - alternatively you may surf to gather necessary data). Write a C++ program that declares a struct type named "VideoCollection", which will form a very simple database of information on popoular movies. The following information should be included in the struct: - Short description of the video (10 words or less) - Names of two of the actors/actresses - Year Released - Length of video, minutes - Your rating, on a scale of 1.0-10.0 (lower=bad, higher=good) Other information that may be listed about the movie need not be included. For the purpose of this exercise, the program can get the data in one of three ways (you pick): - Coding an input routine to prompt the user - "Hard code" it directly into the program - Read it in from a file Regardless of which way you chose to have the data entered, use the struct data entered to produce the information back in table form. After making the table, have the program determine the following information for a minimum of 8 movies entered: - Average movie length, hours:minutes - Minimum movie length, hours:minutes - Maximum movie length, hours:minutes The program will determine the above data from the struct member info. An example table appears below (only 3 of the 8 or more videos are shown), with length statistics below it: Title | Actors/Actresses |Year|L(Min)|Rating/10 ----------------------------------------------------------------- Batman | Micheal Keaton, Jack Micholson |1989| 126 | 9.4 MI2 | Tom Cruise, Anthony Hopkins |2000| 123 | 6.1 - | - - - - | - | - | - - | - - - - | - | - | - - | - - - - | - | - | - Avatar | Sam Worthington, Sigourney Weaver |2009| 162 | 8.2 Average Movie Length = 2:12 Minimum Movie Length = 1:27 Maximum Movie Length = 2:49