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

If one won''t explicitly call the destructor of a local then , if one won't...

if one won't explicitly call the destructor of a local; then how does he handle the above situation?

Define the volatile keyword qualifiers in c language, Define the Volatile K...

Define the Volatile Keyword Qualifiers in C Language? The volatile keyword proceed as a data type qualifier and a volatile variable is for dynamic use. E.G. for data that is to

Static data members and static member function, Static Data Members: A ...

Static Data Members: A data member inside the class can construct as static data member.   There are few guidelines to be followed when declaring static data member.

The Shell or Command Line Interpreter is the fundamental Use, 1. The shell ...

1. The shell must support the following internal commands: i. cd - Change the current default directory to . If the argument is not present, report the current directory. If t

What is the issue which auto_ptr objects address?, A: If you employ auto_pt...

A: If you employ auto_ptr objects you would not need to be concerned along with heap objects not being deleted even if the exception is thrown.

Explain the #undef directive, The #undef Directive This directive undef...

The #undef Directive This directive undefines a previously explained macro. For, example the following will give an error since PI is undefined.                 #define PI 3

Write a program to illustrate array, Write a Program to illustrate Array? ...

Write a Program to illustrate Array? int x[100]; char text[80]; float temp[30]; static int marks[5]; We are able to use symbolic constants instead of expression. The valu

Write a program that illustrate command line parameters, Write a Program th...

Write a Program that illustrate Command Line Parameters? main(int argc, char *argv[]) { int i; for(i = 0; i printf("arg %d: %s\n", i, argv[i]); return 0; }

Minimum shelf, At a shop of marbles, packs of marbles are prepared. Packets...

At a shop of marbles, packs of marbles are prepared. Packets are named A, B, C, D, E …….. All packets are kept in a VERTICAL SHELF in random order. Any numbers of packets with thes

Car rental project, I need a project on car rental system using c programmi...

I need a project on car rental system using c programming only of college level

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