COMP1400 Lab6-Working with basic types and more with loops Solved

30.00 $

Category:
Click Category Button to View Your Next Assignment | Homework

You'll get a download link with a: zip solution files instantly, after Payment

Securely Powered by: Secure Checkout

Description

5/5 - (1 vote)

Pin code security check: The Hogwarts School was so happy with your math helper program that they referred you to a security firm! This security firm creates pin code door lockers like you see in the movies. They now need help to design an algorithm that will power the authentication system. The algorithm they want to validate codes is pretty weak, but it should work in the following way:

  • It first checks if the pin code entered is five digits. If not, the code is invalid.
  • It then checks if each digit within the five-digit pin is divisible by 3. If not, the code is invalid.
  • If six consecutive invalid pins are entered, the system locks out and reports an intruder.

Therefore, codes 357 and 16343 are invalid because the former is less than five digits and the latter has numbers which are not divisible by 3 (i.e. 1 and 4). A valid pin code could be 63339 because it has exactly five digits. . In addition, all of its five digits (i.e., 1, 3, 5, and 7) are divisible by 3. A sample interaction is shown below

 

 

Enter pin code (attempt 1):

1234
  Code 1234 is invalid!

Enter pin code (attempt 2):

 

12534

  Code 12534 is invalid!

Enter pin code (attempt 3):

Code 63963 is success!

 

63963

 

 

If the user entered more than 6 invalid pins:

 

 

 

Part A: RAPTOR Exercise

  1. Understand more about RAPTOR by watching the video about how to work with subcharts
  2. Start RAPTOR and create the flowchart of pin code security check.
  3. Save the flowchart to a file named “pinCode.rap” in the working directory on the PC you are using.
  4. Demonstrate the pinCode.rap file to GA/TAs and run with different input values.

 

Suggestion: Add a subchart CheckCode to help improving the readability of the flowchart  

 

Part B: C Programming Exercise

  1. Implement the algorithm as represented by “picCode.rap”, and write an equivalent C program that accomplishes what the flowchart does.
  2. Save your program to a file named “picCode.c” in the working directory on the PC you are using.
  3. Demonstrate the picCode.c file to GA/TAs and run with different input values.

 

EVALUATION:

You need to show your GA/TA the complete programs at the end of this lab, or at the beginning of your next lab. The marks you will receive for this lab are made of two parts: Lab work marks 10 and attendance marks 5. Total 15 marks.

 

 

Lab Work Mark: Your C code will be evaluated based on your solutions for the problems based on the following scheme:

 

  1. Does the code run and meet specifications?
    • Is input adequate and input data type properly validated?
    • Is processing adequate?
    • Is output correct and adequate?
    • Is the code compliable? Is the code run properly?

 

  1. Is the code properly commented?
    • Is the program title, programmer’s first and last name, and the date posted at the top in a multi-line comment?
    • Is each significant step of the program properly commented?
    • Are comments added to clarify details?
    • Are comments clear, accurate, neatly formatted, and have no misspellings?

 

  1. Is the code properly formatted?
    • Are blocks of code indented according to their parent-child relationship?
    • Do curly braces line up vertically?
    • Is there an empty line between significant steps (blocks) of the program?
    • Is the width of the code contained within a reasonable limit so that minimal horizontal scrolling is required (with 800 x 600 monitor resolution), and there is minimal linewrapping when printed?
    • Is camel-case notation used for variable, e.g. employeeLastName?

IMPORTANT: DO YOUR OWN CODE. ANY CODE SUSPECTED TO BE SIMILAR TO ANOTHER SUBMISSION WILL CAUSE BOTH SUBMISSIONS TO RECEIVE A ZERO MARK ON ALL LABS AND BE REPORTED FOR PLAGIARISM.

 

  • lab6-c54tmw.zip