• +1-617-874-1011 (US)
  • +44-117-230-1145 (UK)
Live Chat
Follow Us:

CSP2151 Workshop 3 2020 Assignment

Edith Cowan University
CSP2151 Programming Fundamentals
Workshop 3 2020 Assignment

Non-assessable tasks:

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.

Practice tasks (optional):

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.

Assessable tasks:

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 <stdio.h>, <stdlib.h>, <time.h>, <math.h> and <string.h>. 

Academic Integrity and Misconduct  

• This workshop is an individual work (not a teamwork). Your entire assignment must be your own work (unless quoted otherwise) and produced for the current instance of the unit. Any use of uncited content that was not created by you yourself constitutes plagiarism and is regarded as Academic Misconduct. All assignments will be submitted to plagiarism checking software, which compares your submission version with previous copies of the assignment, and the work submitted by all other students in the unit (in the current semester or previous years/semesters). 

Never give any part of your assignment to someone else, even after the due date or the results are released. Do not work on individual assignment with other students. – You can help someone by explaining concepts, demonstrating skills, or directing them to the relevant resources. But doing any part of the assignment for them or with them or showing them your work is inappropriate. An unacceptable level of cooperation between students on an assignment is collusion and is deemed an act of Academic Misconduct. If you are not sure about plagiarism, collusion or referencing, simply contact your lecturer or unit coordinator. 

• You may be asked to explain and demonstrate your understandingof the work you have submitted. Your submission should accurately reflect your understanding and ability to apply the unit content and the skills learnt from this unit.

• Before submitting your workshop, make sure you have checked all items in the Academic Integritytick-before-submit checklist below and watch the video by clicking the link next to the checklist image:

Watch this video before submitting your assignment

Workshop Submission Requirements:

• You are required to submit, through Blackboard (BB), a zip file containing at least three files: the design document, the C source code for Assessable tasks (e.g., workshop3.c) and an executable code (i.e., *.exe). An additional C code (e.g., Workshop3_bunos.c) should also be included in the zip file if you have completed the work for bonus marks. Again, unless specifically instructed, email or paper submission is not allowed.

• The Design for this workshop can either be in pseudocode or flowchart and must be in Word or PDF format. The assignment cover sheet is not required but please make sure to include the information such as unit code, Workshop number, year and semester, and your name and student number, etc. in header/footer area (or somewhere else in the first page) of the file. 

• Please rename your zip file as 

CSP2151_Workshop3_<Your Student ID>_< Your full name>.zip. and only submit the single .zip file only.

Note: 

• Only submit your solution to the Assessable part, and possibly to bonus marks part if you attempted (but not for non-assessable part).

• If you don’t know how to prepare and submit a zip file, watch the related video in Assignment section.

• Double check all documents/codes constianed in your submission/zip file and make sure they are the correct version/s before submitting - You should run the code/d again before submitting, to avoid submitting incorrect file versions for marking.

• If you encounter any difficulties when submitting workshop solution through Blackboard, please contact your tutor (Jitian, via j.xiao@ecu.edu.au) and briefly explain the difficulties you experienced (e.g., BB was down, BB doesn’t accept specific type of files, etc.).

• Please keep the copy you submitted (in case your submission to BB was corrupted and you are requested to provide the same copy again).

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  

Design not present or does not meet requirements 

Design has logical flaws or does not meet all requirements 

2

Design meets some requirements but not all or has significant formatting issues

Design meets most requirements but has some issues 

4

Design meets all requirements 

4

Struct/array & repetition etc.  

Structs/arrays/repetition not present 

Structs/arrays are present but are poorly used/have significant errors 

 

Structs/arrays work but have some small errors 

Arrays work to store expected results 

3

Code

Legibility  

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

Functions not present, break scope or use global variables 

 

Functions are present but are poorly structured, contain some errors, or some functions are missing 

 

Functions are present and work as intended 

2

Control

structures

Loops not present

 

loops are present but are poorly structured, contain some errors

 

2

Loops are present and work as intended

2

Compiling  

Code does not compile 

 

Code compiles with some errors/warnings 

 

2

Code compiles with no warnings 

2

Output  

Output is incorrect or not formatted as required

 

1

Output is correct but could be formatted better 

 

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