Program Assignment #3, C/C++ Programming

Assignment Help:
Programming Assignment #3: Vehicle Track Performance Tests
Purpose: The purpose of this programming assignment is to give the student experience in using functions, arrays, and strings. Arrays will be used to store and process data and the graphing capabilities of Excel will be used to graph results calculated by the C++ program.
Reference: The PowerPoint presentation on data files on the instructor’s website includes an example of graphing the output of a C++ program using Excel.
Data file description:
Four data files (CAR1.DAT, CAR2.DAT, CAR3.DAT, and CAR4.DAT) are available on the instructor’s web page. Each file contains track results for a test vehicle. The results are in the following format:
• The test vehicle number (line 1).
• The test date (line 2).
• The test driver (line 3).
• Time, t, in seconds and distance, x, in feet (one pair of (t,x) values per line for all other lines)
As an example, the contents of CAR1.DAT are shown below:
Test vehicle: Car #1
Test date: October 26, 2007
Driver: D. Myers
0.0 0.0
0.2 5.5
0.4 15.9
0.6 30.9
0.8 49.7
1.0 71.8
1.2 97.1
1.4 125.4
1.6 156.6
1.8 190.4
2.0 226.6
2.2 265.3
2.4 306.1
2.6 348.9
2.8 393.5
3.0 439.9
3.2 488.0
3.4 537.7
3.6 588.8
3.8 641.2
4.0 694.6
4.2 749.2
4.4 804.7
4.6 861.2
4.8 918.4
5.0 976.2
Page 2
Determining velocity and acceleration using distance and time values:
Velocity, v, and acceleration, a, can be determined using values of distance, x, and time, t, as follows. By definition: v = dxdt and a = dvdt
These equations can be approximated by: v = change in distancechange in time and a = change in velocitychange in time
For the distance and time values in the data files provided, let’s assume that v = 0 and a = 0 at the first time value (0.0). We could then calculate velocity (in ft/s) and acceleration (in ft/s/s) at the second time value using: v1 = x1 - x0t1 - t0 and a1 = v1 - v0t1 - t0
Similarly at the third time value: v2 = x2 - x1t2 - t1 and a2 = v2 - v1t2 - t1
For the data file CAR1.DAT, this would yield: v1 = 5.5 - 0.00.2 - 0.0 = 5.5 ft0.2 s = 27.5 ft/s a1 = 27.5 - 0.00.2 - 0.0 = 27.5 ft/s0.2 s = 137.5 ft/s2
Similarly: v2 = 15.9 - 5.50.4 - 0.2 = 10.4 ft0.2 s = 52.0 ft/s 2ft/s 122.5 = s 0.2ft/s 24.5 = 0.2 - 0.427.5 - 52.0 = a2
The remaining values could be determined in a similar manner. It might also be more practical to express v in mph that in ft/s. A simple conversion factor can be used to convert v in ft/s to mph.
A table could now be created which includes t, x, v (in ft/s),
v (in mph) and a. This table for CAR1.DAT might look like:
t (s)
x (ft)
v (ft/s)
v (mph)
a (ft/s²)
0.0
0.0
0.0
0.0
0.0
0.2
5.5
27.5
18.8
137.5
0.4
15.9
52.0
35.5
122.5
0.6
30.9
75.0
51.5
115.0
5.0
976.2
289.0
197.0
15.0
Page 3
Program Requirements:
Write a C++ program that will accomplish the following:
1. The program should ask the user which data file is to be used (give an example name and path), read the file name as a string, and open the file using a string variable.
2. The program should read the vehicle number, date, and driver as strings. Also read the values of t and x from the file and store them in arrays. Assume that the data files will contain a maximum of 30 (t, x) data points.
3. Define arrays for velocity (in ft/s), velocity (in mph), and acceleration (in ft/s²). Use a separate function to calculate each of these arrays. For example, the function to find velocity in f/s might be called using Velocity (t,x,v,size) where t and x are input arrays, v is an output array, and size is the number of data points in each array.
4. Write a general function that can be used to find the average of any array. Call this function twice in order to find average velocity (in mph) and average acceleration (in ft/s² or ft/s/s). For example, the function might be called as follows:
Average = ArrayMean(A, Asize); //function call to find mean value in array A
5. Write a general function that can be used to find the maximum of any array. Call this function twice in order to find maximum velocity (in mph) and maximum acceleration (in ft/s² or ft/s/s). For example, the function might be called as follows:
Max = ArrayMax(A, Asize); //function call to find max value in array A
6. The output of the program should be sent to a data file (the name of the data file should be specified by the user, but give an example name and path). The output should include:
• The test vehicle number
• The test date
• The driver
• The average velocity in mph
• The average acceleration in ft/s/s
• The maximum velocity in mph
• The maximum acceleration in ft/s/s
• Values for time, distance, velocity (ft/s), velocity (mph), and acceleration (ft/s/s) for each of the data points in the input data files (i.e., 5 numbers per line).
The file should include commas between each numeric value so that the file can be imported into Excel as a “Commas Delimited File”. The output data file for CAR1.DAT might look as follows:
As an example, the output file generated for the input CAR1.DAT is shown below:
Test vehicle: Car #1
Test date: October 26, 2007
Driver: D. Myers
Average velocity = aaa mph
Average acceleration = bbb ft/s/s
Maximum velocity = ccc mph
Maximum acceleration = ddd ft/s/s
0.0,0.0,0.0,0.0,0.0
0.2,5.5,27.5,18.8,137.5
0.4,15.9,52.0,35.5,122.5
0.6,30.9,75.0,51.5,115.0
·
·
·
5.0,976.2,289.0,197.0,15.0
Page 4
7. Run your program for any two of the data files.
• Import each of the output data files into Excel.
• Add titles to each column, lines, numeric formatting, etc., to enhance the appearance and readability of the data.
• Form four graphs: x vs t, v vs t (in ft/s), v vs t (in mph), and a vs t.
• In addition to standard report requirements, be sure to include a printout of your program, a printout of all 4 input data files, a printout of all 4 output data file, and the spreadsheet table and graphs for the two files that you selected.
Extra Credit Suggestions: (for a maximum of 10 additional points on the program grade)
1. Use additional functions. For example, a function could be used to create an output data file.
2. Give the user the option of specifying standard or SI units (user selects A or B below):
A) distances in the data file are in feet: then calculate v (in ft/s), v (in mph), and a (in ft/s/s)
B) distances in the data file are in meters: then calculate v (in m/s), v (in km/h), and a (in m/s/s)
3. Instead of using five one-dimensional arrays for t, x, v (in ft/s), v (in mph), and a (in ft/s/s), use a single two-dimensional array (5 by 30).
4. Expand the idea above to use a three-dimensional array where the third dimension corresponds to the input data file number (1, 2, 3, or 4). Read all four data files when the program starts to fill the array. The program output should then be automatically sent to the four output data files. No user input would be required in running the program.
5. Use your imagination!

Related Discussions:- Program Assignment #3

Source code, I hv an assignment to do, I almost done. But i cant find whats...

I hv an assignment to do, I almost done. But i cant find whats wrong- my code is to make a simple calculator using function''s all 4 patterns. I did like this- #include int add

M--commerce, Project Description: We are aiming to prepare an industry f...

Project Description: We are aiming to prepare an industry first in the m-commerce world. M-commerce payment processing programmers required Skills required are C Programmi

Define some important point for bit fields with structures, Define some Imp...

Define some Important Point for bit fields with structures? Only n lower bits will be assigned to an n bit number thus type cannot take values larger than 15 (4 bits long)

Decode the code, Smugglers are becoming very smart day by day. Now they hav...

Smugglers are becoming very smart day by day. Now they have developed a new technique of sending their messages from one smuggler to another. In their new technology, they are send

How many non-boundary pits and peaks are on the map, Armed with your functi...

Armed with your function from above, we can do some interesting things. For instance, any pixel where the offsets are both zero is a pit (lower than all surrounding points) .

Area under curve, Write a program to find the area under the curve y = f(x)...

Write a program to find the area under the curve y = f(x) between x = a and x = b, integrate y = f(x) between the limits of a and b.   #include float start_poin

How many ways are there to initialize an int with a constant, There are two...

There are two ways for initializes in C++ as shown in the example that follows. The first way uses the traditional C notation. The second way uses constructor notation. int foo

Why shouldn''t matrix class''s interface look like an array, Why shouldn't ...

Why shouldn't Matrix class's interface look like an array-of-array? A: Some people build a Matrix class that has an operator[] that returns a reference to an Array object (or po

Influence on Social media - for Geek''s, Recently social media has been flo...

Recently social media has been flooded by fb posts, tweets, news articles about only thing demonetization.A great debate is ongoing over it. Most of the people discussing in social

Class & objects, how objects are initialized dynamically?

how objects are initialized dynamically?

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd