# CSP2151 Workshop 3 2020 Assignment

```Edith Cowan University
CSP2151 Programming Fundamentals
Workshop 3 2020 Assignment
```

Lab practice: Design and/or implement

• Write a function is_sorted(int A[], int n) that returns “true” if the array A[0…n-1] is in sorted order.
• Write a function sqmatrix_mult(sqmatrix A, sqmatrix B, sqmatrix C, int n) that calculates the matrix product C = A × B, assuming that each matrix is n by n.
• Write the function strlen(char *s) that returns the length (in characters) of the string indicated by s. If you find it easier to think in terms of arrays, regard the argument as being of type char s[].
• Define a structure to account for this situation:

Cars have six-character registration numbers, and two dates associated with them – the date the car was first registered, and the date that the current registration expires. Each car also has fields (40-byte strings) for manufacturer, make, body type, and colour; and a field to record the number of owners it has had.

Design and implement a program that reads text from the standard input, and writes a list of the distinct words that appear. Words may be limited to a maximum of 10 alphabetic characters. Assume that as many as 1,000 distinct words might appear.

Your next assessable task is to continue creation of the Automated Crash Test Simulation.

Design and implement (in C) the following:

• Create a Vehicle structure with the following fields:
• Vehilcle_Number //of int type
• Vehicle_Manufacturer //string, up to 20 chars
• Vehicle_Name //string, up to 10 chars
• First_Manufactured //of int type, >1950
• Top_Speed //of float type, >=0.0
• Number_Of_Seats //of int type, >0
• Mass //of float type, >0.0

Consider the following list of vehicles that could possibly be used to do the Automated Crash Test Simulation.

Table 1: List of vehicle information

 Vehicle Number Vehicle Manufacturer Vehicle Name First Manufactured Top Speed (km/h) No. of Seats Mass   (kg) 1 Toyota Camry 1995 200 5 1100 2 Bugatti Veyron 2015 415 4 1880 3 Alexander Dennis Enviro400 2015 129 90 11000 … … …

Your program should first create an array of structs, Vehicle_info [ ], that stores vehicle information (using above defined Vehicle struct, or type_def it before use). Your array should be able to store information for up to 50 vehicles. The program should initialize the Vehicle_info[ ] array with appropriate vehicle information for at least 5 vehicles.

• Extend your previous program to simulate the automated crash test using the vehicle information stored in the Vehicle_info Your program should first display all available vehicle information (with a properly designed format) on the screen.
• Prompt the user to enter 2 variables: velocity (km/h) and stopping_distance (m). Display an error massage if any of these variables is entered 0 or less.
• The program then loops to wait the user to enter a Vehicle Number, and then do the following process, until the Vehicle Number entered is -1.

Once a Vehicle Number is entered (e.g., 2), the program searches related information of the corresponding vehicle (e.g., vehicle with Vehicle No. 2) from the Vehicle_info array, and use the information to calculate the Force of Impact (e.g., taking mass value from the Mass column of Vehicle_info array, but velocity and stopping_distance values as just input above). After calculation, it displays relevant/resulting information on screen (you may present whatever format but should contain below information, like)

Vehicle Number, Vehicle name, Mass, Top speed, Test Velocity (km/h), Stopping distance, Force of Impact exposed

Note: Your program should display an error message if something goes wrong, for example, to deal with the following cases:

• If the velocity entered is greater than the top speed of the participating vehicle;
• If the Vehicle Number entered is not in range of available number of vehicles, etc.
• Bonus Marks:

You are encouraged to further extend your program (to a new version of code):

• Add a menu that not only do the above task but also extra functions, such as (i) allowing users create (or enter information for) more vehicles. Use an integer to keep track of number of vehicles that have been created so far.

Be careful – Don’t allow the user to create more than 50;

• displaying vehicle information for all available vehicles including those newly entered/updated;
• allowing searching vehicle information by Vehicle name, etc., instead of Vehicle Number only, etc.
• Explain and extend to accommodate more error messages, etc.

Additional work and effort to improve the program and make it more useful can be worth bonus marks. Up to 2 marks can be added for the above improvement. Again, Bonus marks are not required and will not improve your grade above 100%.

(Note: To obtain the Bonus mark, a new version of codes should be submitted. That is: you need to submit two versions of codes: one version only completed the required Assessable tasks (without any work for Bonus mark), and the other version serves as an advance version containing the work for the required Assessable tasks, together with the work for the bonus mark. For example, you may name your codes “workshop3.c” and “workshop3_bonus.c”, respectively)

## -------------------------The end of the Workshop description -----------------------------

 Design and coding requirements: • The Design: For this workshop, you can use pseudocode or flowchart to complete the design. Your design document should contain separate designs for each of functions, if any. Again, please adhere to the notation used in the unit materials wherever possible. If you can’t do this for some reason, make sure that whatever notation you use is consistently applied and clearly represents the meaning of what you are depicting, and add keys or legends if necessary. • The C code: Your C code must be consistent with your design.  This workshop is to test your understanding of basic programming concepts related to functions, pointers, arrays, strings and structs etc. to assess your ability in using various data structures and control structures to implement small- and/or middlesized programs. Therefore, please try to use these data structures as much as possible and use different types of control structure (such as loops) in your C code. No global variables should be used in this workshop. The only Libraries to be used in this workshop are , , , and .
 Workshop 3 Marking Guide Marking criteria Marks allocated Design /4 Structs, Arrays and Strings and repetition /3 Code legibility (comments, formatting/indentation etc.) /3 Functions/pointers /2 Control structures (loop, decision, etc.) /2 Compilation /2 Output /2 Overall (e.g., code functioning, submission as per submission requirement and design/coding requirements, etc.) /2 Bonus (/2) Total: /20

#### Rubric

 Not proficient Low Proficiency Developing Proficiency Moderate  Proficiency High Proficiency Marks Allocated Design 0  Design not present or does not meet requirements 1  Design has logical flaws or does not meet all requirements 2 Design meets some requirements but not all or has significant formatting issues 3  Design meets most requirements but has some issues 4 Design meets all requirements 4 Struct/array & repetition etc. 0  Structs/arrays/repetition not present 1  Structs/arrays are present but are poorly used/have significant errors 2  Structs/arrays work but have some small errors 3  Arrays work to store expected results 3 Code Legibility 0  Code is very difficult to read 1  Code has many readability issues such as poor naming conventions or lack of indenting 2  Code has some readability issues such as poor naming conventions or lack of indenting 3 Code is well written and highly readable 3 Functions/ pointers 0  Functions not present, break scope or use global variables 1  Functions are present but are poorly structured, contain some errors, or some functions are missing 2  Functions are present and work as intended 2 Control structures 0  Loops not present 1  loops are present but are poorly structured, contain some errors 2 Loops are present and work as intended 2 Compiling 0  Code does not compile 1  Code compiles with some errors/warnings 2 Code compiles with no warnings 2 Output 0  Output is incorrect or not formatted as required 1 Output is correct but could be formatted better 2  Output is correct and formatted as indicated 2 Overall 0 Code doesn’t function. Submission, design /coding not meet requirements 1 Code has functioning issues, design/coding and submission partially followed requirements 2 Code function well; design/coding and submission followed requirements 2

### + Submit Your Assignment Here

#### AssignmentHippo Features

##### On Time Delivery

Our motto is deliver assignment on Time. Our Expert writers deliver quality assignments to the students.

##### Plagiarism Free Work

Get reliable and unique assignments by using our 100% plagiarism-free.

##### 24 X 7 Live Help

Get connected 24*7 with our Live Chat support executives to receive instant solutions for your assignment.

##### Services For All Subjects

Get Help with all the subjects like: Programming, Accounting, Finance, Engineering, Law and Marketing.

##### Best Price Guarantee

Get premium service at a pocket-friendly rate at AssignmentHippo

#### Client Review

I was struggling so hard to complete my marketing assignment on brand development when I decided to finally reach to the experts of this portal. They certainly deliver perfect consistency and the desired format. The content prepared by the experts of this platform was simply amazing. I definitely owe my grades to them.