Written Assignment

  • Create an Algorithm for the process of driving a car. Assume that who you are writing the algorithm for knows nothing about driving – but they do know the rules of the road (what a red light means and a stop sign, etc.). Give your algorithm to a friend and see if they are actually able to drive based on your step by step description!
  • Modularity. What does the term “modularity” mean and what does good modularity in an algorithm do for us? Define (in your own words) modularity and then give three examples of how it can be used as a powerful tool for our algorithms and ultimately our programs.
  • Programming. The purpose of the second program is to continue refining our programming skills in C++ and practice using arrays of characters, functions with arguments. Our goal is to create programs with a small main function that delegates to a series of functions where the real work takes place. In this programming assignment, you are not allowed to use global variables. Limit your main to no more than 20 statements of code (for executable statements… not counting variables or comments).

Program Assignment

How many times have you been asked to create a password? Do you always use the same password? Do you have to work hard to add capital letters, digits, or special characters as the various instructions require?

You will be creating a password generator, written in two phases. There will be two different .cpp programs that will be turned in once you are done, along with an external data file! You can start with Phase #1 which starts the process. Make sure to break each major concept into a function with arguments so you can get the full benefit of this assignment!

Phase #1: You have decided to write a password generator program that will create a password from a word entered in from the user, reversed. Your program will then add at random locations least one digit, one capital letter, and one special character (such as a #,$,%,&,*, etc.). The special character added must be a printable character so the user will be able to see it. Once your program has created the password, display it to the user.

In this program you will need to use the random number generator. There are two function needed to use this from the cstdlib library (standard library header file) and ctime:

  • * srand(time(0); to see the random number generator
  • * rand() which will return a random number
  • Ask the user for their password choice
  • Read in the user’s response
  • Error check the user’s input
    • Only allow the user to enter in alphabetic values (a-z, A-Z)
    • Valid choices could either be upper or lower case
  • Reverse the order of the characters
  • Randomly add at least one digit, one capital letter and one special character.
  • Output the result to the user to see if it is acceptable
  • Continue this process until the user has asked to quit
  • Once the user is satisfied, read in their secret question that will be ultimately tied to this password.

Phase #2: The next step would be to store the password and secret question in an external file (encrypted, of course!). Then create a second program that is “password protected”. In order for that program to begin properly, it will ask for the user’s password – if it matches the one in the external data file, then you have success! Otherwise, display the secret question to see if the user – given some hints – can get the password correct. Try to have fun with this part! Think of this as just step 1 of a larger problem.

***You are always welcome to do more! But, really focus on making general purpose functions that can be re-used. Anytime you have code that has already existed elsewhere (such as to error check input or give the user another chance), write a function instead! Things you should know...as part of your program:

  • Make sure to prompt the user for any input requested. Make sure it is clear from your prompts what the user is expected to do.
  • You may not use any global variables in this program!
  • The program should continue until the user wants to quit. Allow them to continue until they are done.
  • You may not use any global variables in this program!
  • You may not use the string class – instead use arrays of characters
  • Make sure to use C++’s I/O (iostream library) for your input and output.
  • FUNCITONS are required for this assignment, along with BOTH pass by value and pass by reference!
Academic Honesty!
It is not our intention to break the school's academic policy. Posted solutions are meant to be used as a reference and should not be submitted as is. We are not held liable for any misuse of the solutions. Please see the frequently asked questions page for further questions and inquiries.
Kindly complete the form. Please provide a valid email address and we will get back to you within 24 hours. Payment is through PayPal, Buy me a Coffee or Cryptocurrency. We are a nonprofit organization however we need funds to keep this organization operating and to be able to complete our research and development projects.