105 Concrate_Wall concrate 6000 201 Car vehicle 1100 3 Bus vehicle 3100 4 Truck vehicle 2220 5 Steel Board metal 36 16 K
Posted: Thu May 26, 2022 9:17 am
1525 Toyota Camry 1998 200.00 5 1100.00 2014 Bugatti Veyron 2015 310.00 4 1880.00 30 Tesla Model6 2021 360.00 6 1200.00 404 Hyundai Getz 2010 140.00 5 1000.00 3455 Mazda Mazda3 2019 230.00 5 1100.00 26 Suzuki Swift 2011 220.00 5 1000.00 77 Datsun GO+ 2009 220.00 8 1400.00 128 Audi Cabriolet 2014 212.00 5 1300.00 19 Volvo S60 2021 180.00 5 1500.00 10 Maruti Ciaz 2018 190.00 3 1200.00
The tasks: Design and implement (in C) the following tasks to complete and manage the AVCS system (please refer to detailed description of the AVCS system in Workshop 1 description). 1) Application scenario pre-setting: a) Key data structures: Create three structures (see below) and typedef them as new data types (also refer to Workshop 3): struct Vehicle ( //int type Vehilcle_number Vehicle_manufacturer Vehicle_name //string, up to 20 chars, contains no space //string, up to 10 chars, contains no space** //int type, >1950 Year manufactured Top speed //float type, >=0.0 //int type, >0 Number of seats Mass //float type, >0.0 Typedef a new data type, vehicle_t, for the above structure: #typedef struct Vehicle vehicle_t; struct Obstacle ( //int type Obstacle number Obstacle_name Obstacle texture //string type, up to 32 chars, contains no space ** //string type, up to 20 chars, contains no space ** //float type, > 0.0 Obstacle mass Then typedef a new data type, obstacle_t, for the above structure: Page 1 of 11
Assignment 2 #typedef struct Obstacle obstacle_t; struct Vehicle_simulation { Test ID Vehicle ID Obstacle ID Vehicle_age Impact_velocity Number of passengers Number of //int type, ID of vehicle being tested // int type, ID of obstacle being tested // int type, Test condition 1, >=0 //float type, Test condition 2, >0.0 // int type, Test condition 3, >=0 // int type, Test condition 4, >=0 // float type, Test result 1 (calculated) // float type, Test result 2 (calculated) // float type, Test result 3 (calculated) seatbelt_wearing_passengers Safety rate Damage_rate Passenger_survival_rate Then typedef a new data type, simulation_t, for the above structure: #typedef struct Vehicle_simulation simulaion_t; You may add any extra field/s as needed to the above structs. b) Some key variables: o vehicle_info[]: an array of type vehicle_t, used to hold vehicle information of up to 50 vehicles. o vehicle_count: a variable (of type int) used to keep track of the number of vehicles stored in the array of vehicle_info[]. o current vehicle: a variable of type vehicle_t, used to hold information of the current vehicle being under simulation. o obstacle_info[ ]: an array of type obstacle_t, used to hold information of up to 20 obstacles; o obstacle_count: a variable (of type int) used to keep track of the number of obstracles stored in the array of obstacle_info[]. o current obstacle: a variable of type obstacle_t, used to hold information of the current obstacle being under simulation. c) Initialization data: Some data for vehicles are given in the attached text file vehicle_c.txt, and data for obstacles are in obstacle_c.txt. You may use the data in these files to initialise related arrays in your code (refer to Table 1 in Workshop 3 for possible vehicle information). CSP2151 sem1, 2022
2) The AVCS system Your program should first declare a few key variables (see above section). It then loads data from the files "vehicle_c.txt" and "obstacle_c.txt" to initialize the array of vehicle_info[ ] and obstacle_info[], respectively. You should use the variable vehicle_count to keep track of the number of vehicles stored in the array of vehicle_info [ ] and use obctacle_count to keep track of the number of obstacles stored in obstacle_info [ ]. The program then displays all available information stored in the array of vehicle_info[] on screen (using a tabular format, like Table 1 in Workshop 3). Similarly, display all available information stored in the array of obstacle_info[ ] in a tabular format. Page 2 of 11
The program 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 simulation results 8. Save vehicle/obstacle information 9. Exit Menu design/implementation requirement: You should create one function for each menu item (Le, to implement its feature/s). If any of these functions was not implemented as required in the final submission, usea dummy function that prints the following statement instead menu item name feature has not been completed yet." For example, if the "Save all simulation results feature was not completed at submission, the function should print the following statement only "Save all simulation results feature has not been completed yet."
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”, the program displays information of all vehicles. The "Search an obstacle" feature is similar to that of "Search a vehicle", but it searches information of an obstacle instead of a vehicle. The "Input/update vehicle information" feature allows the user to input or update information of ONE vehicle. It prompts the user to input a Vehicle_Number (of a vehicle to be created/updated), followed by other data items of a vehicle. 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 entered should be stored in the new entry (and the total number of students increased). In the case of updating, the program should give a chance to allow the user to confirm whether to update the current information (before action). If a new vehicle is created, ensure that the total number of vehicles be less than or equal 50. The "Input/update obstacle information" feature is similar to the previous feature, however it inputs/updates ONE obstacle instead of ONE vehicle. The "Simulate a vehicle crash against an obstacle" feature should allow the user to select ONE vehicle and ONE obstacle (from the respective arrays), and simulate a vehicle crash scenario. This feature can also be named "vehicle crash simulation" (or "vehicle test" for
The "Display simulation results" feature should allow the user to choose a vehicle by its vehicle number or name and display all test simulation results against obstacles (if any). 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 simulation results of the vehicle/s. If multiple vehicles have the same vehicle number or name (e.g., they have done multiple test), all test results for vehicles with that number or 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 simulation 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 of all vehicles that have been tested to the file. The "Save vehicle/obstacle information" feature should extract all vehicle information stored in the vehicle array and save them to a file named "new_Vehicle.txt", and extracts all obstacle information stored in the obstacle array and save them to a file named "new_Obstacle.txt". For simplicity, only the first (up to) 10 pieces of information of vehicles/obstacles are required to save. The "Exit" option ends the program. This should be the only way the program quits except for abnormal cases such as failing to open files to preload data at the start of the program or being unable to write data out to files in some features.
except for abnormal cases such as failing to open files to preload data at the start of the program or being unable to write data out to files in some features. 3) Vehicle crash test simulation This task simulates a vehicle crash scenario, completing calculations on various data items, and displaying (and saving) 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, and stopping_distance of the obstacle, etc.) for the crash test simulation. Note: A simulation of a vehicle crash test simulation system can be much more complicated in the real-world scenario, as there would be many more variables to consider when designing such a system. We will only design and implement a simplified version of such a system in this assignment. Vehicle crash test simulation can be done automatically (i.e., under random conditions: test data and conditions are randomly generated within reasonable value ranges), or manually (i.e., by entering a set of test data or condition/s), or in a hybrid case (i.e., in a weighted combination of the above two cases). - Due to time and workload constraints, we only perform a simulation manually in this assignment (that is, simulation data and/or conditions are entered manually).
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 (of a vehicle) 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 • Stopping distance (of an obstacle) o Displayed/entered in meter o Must not be less than zero • Number of passengers 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
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. Note: To avoid possible dead looping, you may consider setting special data item/s to be used for the user to terminate the current menu option, therefore, to jump out of the current simulation. Based on the above information, the program 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. Calculation of Safety_rate Each test condition confers a bonus or penalty to the overall percentage Safety rate of the test. The Safety_rate is calculated using the following steps/algorithm: a) Safety_rate= 1.0; // initialized as a percentage value of 100% b) Decrease Safety_rate by a percentage factor of the vehicle's age, age factor using.
CSP2151 b) Decrease Safety rate by a percentage factor of the vehicle's age, age factor, using: (0.0 if vehicle age 52 age factor0.5 (vehicle age-2), if 2 < vehicle age 22 10.0 . if vehicle age > 22 (Note: a percentage factor of x is equal to x%, or x/100) Page 5 of 11 Assignment 2 sem1, 2022 c) Decrease Safety rate by F/10000.0, where F is the approximate impact force on the vehicle, and mp² F=2