CYBR 210 – Final Project Name:_________ _____ 1) (3 Points) Write a function definition for a bool function called isEven. This function takes an integer value parameter, and returns boolean value...

See attached.


CYBR 210 – Final Project Name:_________ _____ 1) (3 Points) Write a function definition for a bool function called isEven. This function takes an integer value parameter, and returns boolean value true if the parameter is even and false if it is odd. Write a simple driver program to test your function. Show your full source code and a screenshot of your output. (Chapter 9) 2) (10 Points) In a well-written paragraph, describe the the concepts of abstraction, encapsulation, information hiding, and formal interfaces. Descibe how C++ classes and objects make use of these concepts. Include the role of access modifiers in your discussion. (Chapter 12) Abstraction refers to how the unnecessary detailed data is hidden; it only provides essential information. Encapsulation, however, hides the code and data in a single unit, basically protecting it from other classes and can only be accessed by its current class. In information hiding, the details of an object or function are hidden; this results in abstraction. 3) (2 Points) Describe the role of the heap when using dynamic data. Why would a programmer prefer to use dynamic data? (Chapter 14) A heap organizes is a data structure that has a tree-like formation. In dynamic data, the operating system reserves a block of memory for a program that can be used how the programmer chooses. Once done, it’s returned to the operating system for reuse by another program. 4) (10 Points) The next two problems introduce command-line arguments. Command-line arguments are commonly used in console-based applications. They afford the operator the ability to execute a program by passing in arguments from the command line. We need add two arguments to our main() function. The first argument is an int that contains the number of command line arguments, the second argument is an array of char pointers, which contain the actual command line arguments. The command line argument values are stored in an array, and can be accessed to perform different tasks. The first command line argument, argv[0] is always the name of the executable file. The remaining arguments can be accessed by indexing into the array. For example, the next argument would be located in argv[1]. When writing programs with command line arguments, it is important to clarify the program’s usage. This way the operator knows how to execute the program with the correct arguments. Here is an example program where the user enters a filename as a command line argument and the program performs a word count on the file. #include #include using namespace std; //Pre: inFile is open //Post: Returns number of words in file int wordcount(ifstream& file) { int count = 0; string word; while(file >> word) { count++; } return count; } //Pre: None //Post: Prints Program Usage void printUsage(char exeName[]) { cout < "\n\tusage:="" "="">< exename="">< "="" [filename]\n";="" cout="">< "\n\tprogram="" returns="" wordcount="" of="" filename.\n\n";="" }="" int="" main(int="" argc,="" char*="" argv[])="" {="" make="" sure="" user="" enters="" proper="" number="" of="" arguments="" if="" (argc="" !="2)" {="" printusage(argv[0]);="" return="" 1;="" }="" file="" is="" a="" command="" line="" argument="" ifstream="" infile;="" infile.open(argv[1]);="" check="" to="" see="" if="" file="" exists="" if(!infile)="" {="" cout="">< "\n\t**error="" opening="" input="" file.\n\n";="" return="" 1;="" }="" int="" wc="wordcount(inFile);" cout="">< wc="">< endl;="" infile.close();="" return="" 0;="" }="" your="" task="" is="" to="" write="" a="" program="" called="" “count”="" that="" lets="" the="" user="" retrieve="" a="" word="" count="" or="" a="" letter="" count="" of="" a="" file="" that="" is="" passed="" as="" a="" command="" line="" argument.="" the="" user="" enters="" a="" flag="" (-l="" or="" -w)="" to="" indicate="" if="" they="" want="" a="" letter="" count="" (-l)="" or="" word="" count="" (-w).="" see="" the="" figure="" below="" for="" an="" example="" of="" the="" program’s="" output.="" you="" must="" use="" a="" switch="" statement="" to="" handle="" the="" options.="" you="" should="" also="" have="" at="" least="" three="" functions:="" one="" to="" print="" the="" usage,="" one="" to="" handle="" the="" word="" count,="" and="" one="" to="" handle="" the="" letter="" count.="" the="" program="" must="" be="" executed="" from="" a="" command="" line="" environment.="" show="" full="" source="" code="" and="" a="" screenshot="" of="" your="" working="" program.="" 5)="" (10="" points)="" let’s="" experiment1="" with="" command="" line="" arguments="" some="" more.="" suppose="" we="" need="" integers="" as="" command="" line="" arguments.="" we="" will="" need="" to="" use="" the="" atoi()="" function="" provided="" in="" stdlib.h="" to="" convert="" the="" char*="" argv[]="" values="" to="" integers.="" atoi()="" stands="" for="" “ascii="" to="" int.”="" here="" is="" an="" example="" program="" that="" prints="" the="" sum="" of="" three="" integers="" entered="" as="" command="" line="" arguments.="" #include=""> #include using namespace std; void printUsage(char exeName[]) { cout < "\n\tusage:="" "="">< exename="">< "="" [int]="" [int]="" [int]\n";="" cout="">< "\n\treturns="" the="" sum="" of="" the="" 3="" int="" command="" line="" arguments.\n\n";="" }="" int="" main(int="" argc,="" char*="" argv[])="" {="" if="" (argc="" !="4)" {="" printusage(argv[0]);="" return="" 1;="" }="" int="" a="atoi(argv[1]);" int="" b="atoi(argv[2]);" int="" c="atoi(argv[3]);" int="" sum="a" +="" b="" +="" c;="" cout="">< sum="">< endl;="" return="" 0;="" }="" a="" more="" elegant="" implementation="" would="" be:="" int="" sum="0;" for="" (int="" i="1;" i="">< 4; i++) { sum += atoi(argv[i]); } your task is to write a c++ program that consumes integer values as command line arguments and returns the arithmetic mean of these values. to increase the flexibility of the program, there should be no set number of arguments. to overcome this, we will require the argument argv[1] to be the number of integers the user enters. for example, if the user wants to calculate the arithmetic mean of 4 numbers, they would pass in 4 as the first argument and then the 4 numbers as the remaining arguments. here is an example of how the program should look in execution: in this example, avg is the name of the executable and the user wants the average of 4 numbers, which are 5, 9, 2, and 11. the program then prints the arithmetic mean (average). the benefits of command line arguments should now be obvious. the user simply enters in the name of the executable program followed by the arguments. this saves time for the user by reducing interactivity. it also enables programs to be more easily scripted for automating tasks. include a usage statement as shown in the above addition example. since we will need to perform division between two integers, be cautious of type casting. your program must make use of functions. show your full source code and a screenshot of your running program. 6) (65 points) we are going to design and build an authentication program that lets users create new accounts and login to existing accounts. when launched, the program prompts a menu. i recommend creating a void function called printmenu() that prints the menu and primes the program for the user to enter an option. recall that ‘\t’ prints a tab and ‘\n’ prints a carriage return to help format our output. use a switch statement to handle the menu option. if the user enters option 1, then a login() function is invoked, which authenticates a user. if option 2 is entered, then a createaccount() function is invoked, which creates a new user account. if option 3 is entered, then the program terminates. include a default case to handle invalid entries. you should have a do-while loop. inside the loop, the printmenu() function is invoked and the user’s option is obtained. following is the switch statement. the termination condition for the do-while loop should be while the user’s input is not equal to 3. this design lets the user create numerous accounts and login without having to re-execute the program. when creating a new account, the program prompts the user for a first name and a last name. it then creates a username for the user, which is the first four characters of the last name and the first character of the first name. for example, if i enter “adam duby” as my name, then the program will generate “dubya” as my username. the username must be in all lowercase. therefore, the program should include a routine that converts the username to all lowercase. the program then prompts for a password. the password must be at least 10 characters long and it cannot contain any whitespace. if the user’s password does not meet the length requirement, then the program displays a message and asks the user to try again. there needs to be a database to store user credentials. the program reads and writes a text file, called creds.txt, which stores usernames and passwords. use the fstream::app modifer when opening the output file stream to make sure that new accounts are appended to the creds database and do not overwrite exisiting account information. the creds.txt database should store account information in the format username:password. the username and password are stored on the same line, seperated by a colon. each username and password combination should be on its own line in the database. it is not secure to store passwords in plain text, so they should be stored in an encrypted form. store the passwords in a rot-13 encrypted format. here is an example of a creds.txt file: the passwords are stored in encrypted form. upons successful creation of a new account, the program primts a message and notifies the user of their username and new email address. the email address is of the form [email protected]. when logging in, the program prompts for the username and password then checks the creds.txt database to see if there is a match. if a match is found a welcome message is generated. if no match is found, a login failure message is generated. some things to keep in mind while designing your program: · what happens if a user has a last name less than four characters in length? your software should be able to handle this. one way is to add letters to the end of the last name 4;="" i++)="" {="" sum="" +="atoi(argv[i]);" }="" your="" task="" is="" to="" write="" a="" c++="" program="" that="" consumes="" integer="" values="" as="" command="" line="" arguments="" and="" returns="" the="" arithmetic="" mean="" of="" these="" values.="" to="" increase="" the="" flexibility="" of="" the="" program,="" there="" should="" be="" no="" set="" number="" of="" arguments.="" to="" overcome="" this,="" we="" will="" require="" the="" argument="" argv[1]="" to="" be="" the="" number="" of="" integers="" the="" user="" enters.="" for="" example,="" if="" the="" user="" wants="" to="" calculate="" the="" arithmetic="" mean="" of="" 4="" numbers,="" they="" would="" pass="" in="" 4="" as="" the="" first="" argument="" and="" then="" the="" 4="" numbers="" as="" the="" remaining="" arguments.="" here="" is="" an="" example="" of="" how="" the="" program="" should="" look="" in="" execution:="" in="" this="" example,="" avg="" is="" the="" name="" of="" the="" executable="" and="" the="" user="" wants="" the="" average="" of="" 4="" numbers,="" which="" are="" 5,="" 9,="" 2,="" and="" 11.="" the="" program="" then="" prints="" the="" arithmetic="" mean="" (average).="" the="" benefits="" of="" command="" line="" arguments="" should="" now="" be="" obvious.="" the="" user="" simply="" enters="" in="" the="" name="" of="" the="" executable="" program="" followed="" by="" the="" arguments.="" this="" saves="" time="" for="" the="" user="" by="" reducing="" interactivity.="" it="" also="" enables="" programs="" to="" be="" more="" easily="" scripted="" for="" automating="" tasks.="" include="" a="" usage="" statement="" as="" shown="" in="" the="" above="" addition="" example.="" since="" we="" will="" need="" to="" perform="" division="" between="" two="" integers,="" be="" cautious="" of="" type="" casting.="" your="" program="" must="" make="" use="" of="" functions.="" show="" your="" full="" source="" code="" and="" a="" screenshot="" of="" your="" running="" program.="" 6)="" (65="" points)="" we="" are="" going="" to="" design="" and="" build="" an="" authentication="" program="" that="" lets="" users="" create="" new="" accounts="" and="" login="" to="" existing="" accounts.="" when="" launched,="" the="" program="" prompts="" a="" menu.="" i="" recommend="" creating="" a="" void="" function="" called="" printmenu()="" that="" prints="" the="" menu="" and="" primes="" the="" program="" for="" the="" user="" to="" enter="" an="" option.="" recall="" that="" ‘\t’="" prints="" a="" tab="" and="" ‘\n’="" prints="" a="" carriage="" return="" to="" help="" format="" our="" output.="" use="" a="" switch="" statement="" to="" handle="" the="" menu="" option.="" if="" the="" user="" enters="" option="" 1,="" then="" a="" login()="" function="" is="" invoked,="" which="" authenticates="" a="" user.="" if="" option="" 2="" is="" entered,="" then="" a="" createaccount()="" function="" is="" invoked,="" which="" creates="" a="" new="" user="" account.="" if="" option="" 3="" is="" entered,="" then="" the="" program="" terminates.="" include="" a="" default="" case="" to="" handle="" invalid="" entries.="" you="" should="" have="" a="" do-while="" loop.="" inside="" the="" loop,="" the="" printmenu()="" function="" is="" invoked="" and="" the="" user’s="" option="" is="" obtained.="" following="" is="" the="" switch="" statement.="" the="" termination="" condition="" for="" the="" do-while="" loop="" should="" be="" while="" the="" user’s="" input="" is="" not="" equal="" to="" 3.="" this="" design="" lets="" the="" user="" create="" numerous="" accounts="" and="" login="" without="" having="" to="" re-execute="" the="" program.="" when="" creating="" a="" new="" account,="" the="" program="" prompts="" the="" user="" for="" a="" first="" name="" and="" a="" last="" name.="" it="" then="" creates="" a="" username="" for="" the="" user,="" which="" is="" the="" first="" four="" characters="" of="" the="" last="" name="" and="" the="" first="" character="" of="" the="" first="" name.="" for="" example,="" if="" i="" enter="" “adam="" duby”="" as="" my="" name,="" then="" the="" program="" will="" generate="" “dubya”="" as="" my="" username.="" the="" username="" must="" be="" in="" all="" lowercase.="" therefore,="" the="" program="" should="" include="" a="" routine="" that="" converts="" the="" username="" to="" all="" lowercase.="" the="" program="" then="" prompts="" for="" a="" password.="" the="" password="" must="" be="" at="" least="" 10="" characters="" long="" and="" it="" cannot="" contain="" any="" whitespace.="" if="" the="" user’s="" password="" does="" not="" meet="" the="" length="" requirement,="" then="" the="" program="" displays="" a="" message="" and="" asks="" the="" user="" to="" try="" again.="" there="" needs="" to="" be="" a="" database="" to="" store="" user="" credentials.="" the="" program="" reads="" and="" writes="" a="" text="" file,="" called="" creds.txt,="" which="" stores="" usernames="" and="" passwords.="" use="" the="" fstream::app="" modifer="" when="" opening="" the="" output="" file="" stream="" to="" make="" sure="" that="" new="" accounts="" are="" appended="" to="" the="" creds="" database="" and="" do="" not="" overwrite="" exisiting="" account="" information.="" the="" creds.txt="" database="" should="" store="" account="" information="" in="" the="" format="" username:password.="" the="" username="" and="" password="" are="" stored="" on="" the="" same="" line,="" seperated="" by="" a="" colon.="" each="" username="" and="" password="" combination="" should="" be="" on="" its="" own="" line="" in="" the="" database.="" it="" is="" not="" secure="" to="" store="" passwords="" in="" plain="" text,="" so="" they="" should="" be="" stored="" in="" an="" encrypted="" form.="" store="" the="" passwords="" in="" a="" rot-13="" encrypted="" format.="" here="" is="" an="" example="" of="" a="" creds.txt="" file:="" the="" passwords="" are="" stored="" in="" encrypted="" form.="" upons="" successful="" creation="" of="" a="" new="" account,="" the="" program="" primts="" a="" message="" and="" notifies="" the="" user="" of="" their="" username="" and="" new="" email="" address.="" the="" email="" address="" is="" of="" the="" form="" [email protected].="" when="" logging="" in,="" the="" program="" prompts="" for="" the="" username="" and="" password="" then="" checks="" the="" creds.txt="" database="" to="" see="" if="" there="" is="" a="" match.="" if="" a="" match="" is="" found="" a="" welcome="" message="" is="" generated.="" if="" no="" match="" is="" found,="" a="" login="" failure="" message="" is="" generated.="" some="" things="" to="" keep="" in="" mind="" while="" designing="" your="" program:="" ·="" what="" happens="" if="" a="" user="" has="" a="" last="" name="" less="" than="" four="" characters="" in="" length?="" your="" software="" should="" be="" able="" to="" handle="" this.="" one="" way="" is="" to="" add="" letters="" to="" the="" end="" of="" the="" last="">
Oct 18, 2021
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here