Reference no: EM132672371
CSP2151 Programming Fundamentals - Edith Cowan University
Assignment: A mini-programming project
General Information:
This assignment is an extension of the Workshops you have been doing during the semester. Like all workshop assessments, this assessment component should be completed individually.
Where appropriate, the standards set out in previous workshops should be followed and the code must make good use of functions, structures and control flows, etc.
Assignment type: individual work (i.e., not a group assignment)
Tasks:
Design and implement the following tasks (in C) to manage the simulation of the Automated Crash Test system.
Your program should first load the information of up to 10 vehicles from a file named "Vehicle.txt" and load the information of up to 10 obstacles from a file named "Obstacle.txt" and store them in two arrays of structures, one for vehicles and the other for obstacles. Use two variables, say vehicle_count and obstacle_count, respectively, to keep track of the numbers of vehicles and obstacles stored in the array of vehicle array and obstacle array, respectively. The minimum requirement for the data structures representing a vehicle and an obstacle, respectively, can be found from Section (1).
The program then displays all available vehicle information, and all obstacle information stored in the relevant arrays of structures. It then displays a Menu that allows the user to navigate through and execute the following options:
1. Search a vehicle
2. Search an obstacle
3. Input/update vehicle information
4. Input/update obstacle information
5. Simulate a vehicle crash against an obstacle
6. Display simulation results
7. Save all results
8. Save vehicle/obstacle information
9. Exit
The "Search a vehicle" feature should allow the user to search for information of a vehicle by its Vehicle_Name. If found successfully, the information stored in the related entry/entries in the vehicle array will be displayed. Otherwise, an error message should be displayed.
As a special case, if the vehicle name entered is "all", it displays information for all vehicles.
The "Search an obstacle" feature is similar to that of "Search a vehicle", but it searches information of an obstacle instead.
The "Input/update vehicle information" feature allows the user to input or update information of a vehicle. It prompts the user input a Vehicle_Number. If the Vehicle_Number entered matches an existing vehicle, the information entered is used to update the information of the vehicle stored in the array of vehicles. Otherwise a new entry should be created in the array of vehicles and information be stored there (and the total number of vehicles should be increased).
The "Input/update obstacle information" feature is similar to the above, however it inputs/updates an obstacle instead of a vehicle.
The "Simulate a vehicle crash against an obstacle" feature should allow the user to select a vehicle and an obstacle (from the respective arrays), and then simulate a vehicle crash scenario. This feature can also be named "vehicle crash simulation" (or "vehicle test" for short). Detailed simulation task is described in the section "(2) Vehicle crash test simulation".
The "Display simulation results" feature should allow the user to choose a vehicle (e.g., by its vehicle name) and display all test simulation results against obstacles. If the vehicle has not yet been tested (i.e., no simulation was recorded), the program should inform the user that they must test that vehicle before displaying any results of the vehicle/s. If multiple vehicles have the same name (e.g., they are with different vehicle numbers), all test results for vehicles with that name should be displayed.
As a special case, if the vehicle name entered is "all", the program should display the test results of all vehicles that have been tested. If none of vehicles have been tested, an error message should be displayed.
The "Save all results" feature should display an error message if no vehicle has been tested. Otherwise it creates a file, named "results.txt", and save the test results for all vehicles that have been tested to that file.
The "Save vehicle/obstacle information" feature should extract all vehicle information stored in the vehicle array and save them back to the "Vehicle.txt" file. It also extracts all obstacle information stored in the obstacle array and save them back to the "Obstacle.txt" file for possible future tests. For simplicity, only the first (up to) 10 pieces of information of vehicles/obstacles are required to save.
(1) Data structures for Vehicles and Obstacles
The structure of a vehicle:
Referencing the Vehicle structure defined in your Workshop 3, define a new structure to represent a vehicle for the crash simulation purpose. Your vehicle structure should include at least 6 fields, including Vehicle_number, Vehicle_name, Manufactur_date, Top_speed, Mass, Number_of_seats. You may add any extra field/s as needed.
The structure of an Obstacle:
The Obstacle structure should include at least 3 fields, Obstacle_number, Obstacle_Name and Stopping_distance. You may add any extra field/s as needed.
The structure of vehicle simulation result:
To save the simulation result, you may create an array of structure for simulation results, and save all simulations results to the array. The Simulation structure may have the following fields (you may add extra fields as needed):
• Test ID
• Vehicle ID // or VehicleName?
• Obstacle ID // or Obstacle Name?
• Vehicle_age // Test condition 1
• Impact_velocity // Test condition 2
• Number_of_passengers // Test condition 3
• Number_of_seatbelt_wearing_passengers // Test condition 4
• Safety_rate //Test result 1 (calculated)
• Damage_rate //Test result 2 (calculated)
• Passenger's Survival_rate //Test result 3 (calculated)
(2) Vehicle crash test simulation
This task simulates a vehicle crash scenario, completing calculations on various data items, and displaying test simulation result.
At the start, the function/program prompts the user to choose one vehicle from the available vehicles and one obstacle from the available obstacles. It then prompts user to enter a variety of test conditions (including the velocity, or alternatively named impact_velocity, of the vehicle) for the crash test simulation.
The test conditions are set as follows and must comply with the listed restrictions:
• Vehicle_age
o Measured in years
o Must not be greater than the current date minus the Vehicle manufacture date or less than zero
• Impact_velocity
o Displayed/entered in km/h
o Use m/s in calculations
o Must not be greater than the Vehicle's top speed or less than zero
• Number_of_passengers
o Must not be greater than the number of seats of the Vehicle stored in the array of Vehicle_info[ ] or less than zero
• Number_of_seatbelt_wearing_passengers
o Must not be greater than the number of passengers or less than zero
If the user enters an invalid value for any test condition, the program should print an error message, together with the data entered, and continue to prompt user again until a valid value is entered.
Based on the above information, the simulation calculates various data items, including Safety_rate and Damage_rate to the vehicle participating the simulation, and Survival_rate of passengers involved in the crash. It then displays (and optionally saves) these data items as the simulation results.
Bonus Mark :
Additional work and effort to improve the program and make it more useful can be worth bonus marks. Bonus marks are not required and will not improve your grade above 100%. - Please do not attempt tasks for bonus mark before you've attempted all required tasks of the assignment.
Examples of features that may be worth bonus marks:
• Advanced search features (search for all simulation/test results above a threshold)
• Use multiple files effectively with appropriate use of header files and good separation of concerns.
• Graphical user interfaces, animations or colours.
• Ask your tutor if you have other ideas!
Design and coding requirements:
• The Design: For this assignment, you can use pseudocode or flowchart to complete the design. Your design file should contain separate designs for each of your functions.
• The C code: Your C code must be consistent with your design.
This is the major assignment of the unit, assessing your ability to solve problems and their knowledge/skills in designing and implementing a medium-sized program based on a given application scenario. You should use correct control structures (sequence, decisions, and loops, functions, etc.) and appropriate or required data structures (arrays, strings, pointers, files, etc.) to implement the program. The only Libraries to be used in this assignment are
<stdio.h>, <stdlib.h>, <time.h>, <math.h>, <string.h>, <errno.h>, and <IO.h>, together with the only head files you created as a part of this assignment work, if any. Other non-standard
or any third-party libraries/packages should not be included/used in the code/s!
Attachment:- Programming Fundamentals.rar