Programming Assignment 6: Web Site Login COP XXXXXXXXXXSpring Term 2020 Point Value: 100 points Project Due Date: Tuesday April 21, 2020 at 11:59 PM Learning Objectives ·To gain experience working...

1 answer below »

Programming Assignment 6: Web Site Login


COP 3014 - Spring Term 2020 Point Value: 100 points


Project Due Date: Tuesday April 21, 2020 at 11:59 PM


Learning Objectives



  • ·To gain experience working with a one-dimensional array of structs

  • ·To practice use of thetypedefconstruct in declaring array types

  • ·To perform a linear search on an array-based list

  • ·To utilize the C++ string class to store and work with textual data


Problem Statement


You have decided to set up your own incredible web site and call itMyGreatWebSite.com. As a start, you are going to write a program to allow registered users to log in. Each user has personal data in the following form:



  • ·userID: a string (no blanks permitted)

  • ·password: a string (no blanks permitted)

  • ·PIN: an integer (4 digits)


To log in, a user must correctly enter all three items. Give the user only THREE tries to enter their data correctly; then they are shut out of the system and your program will exit.




Your program will first read in the data fileusers.txtinto anarray of structs, with each struct represented as follows:


struct UserRecord


{


string userID;


string password;


int PIN;


};


You must set up an array which can handle up to 50 users. The user data has been accurately recorded in the fileusers.txt. The first line of this data file provides the current number of actual users. You must also declare the array of structs type using atypedefas shown in lectures, and utilize this type definition appropriately in your program. You must use C++ string class objects to store and manipulate the string data in this program.


You may assume that the data file is 100% correct and does not need to be checked for errors. You may hard code the file name into your program. If the file does not open on the first try, abort the run.


Processing


First, read in the number of users and then read the user data into your array of structs. Echoprint all input. Print user data in table format.


Now, allow up to three attempts at a log in, for one user. Process one user, then exit the program.


For this one user, prompt them for the ID, password, and PIN, and read these in. Do not do error checking at this time except to make sure that the user enters an integer at the integer prompt (if


2


not, re-prompt until the user does enter an integer). Note that the user might enter strings containing blanks when asked for the name and password and your program must handle this appropriately.


Next, search for the given user ID in the database, and check the password and PIN for a match if the user is found. Use thelinear searchto locate a user.


If all three values are a match in the database for one user, the log in is successful. Tell the user that he/she has successfully logged in, and then exit the program.


If any one or more of the three items do not match a user in the data base, the log in fails. Tell the user and exit the program. DO NOT tell the user why the log in failed. This would make for a less secure system.


Note: in terms of security, for a real-world log in system you would obviouslynotechoprint the list of user names and passwords! However since this is a course project, the graders need to see that you can read and print the array of structs correctly, so that data must be echoprinted.


Output


Set up your output to be clear, informative, and nicely formatted. Remember though, if a non- user is trying to crack into the system, we do not want to be TOO informative or too helpful! For example, we would not tell the user what a user name or password or PIN is supposed to look like.


Use Of Functions, Parameters, Modularity, Design et. al.


Part of your grade on this project will be determined by how well you utilize multiple functions and parameter passing appropriately and how well you design a modular and functionally cohesive program using the principles discussed in class. Large grade point penalties can be incurred for not setting up a modular, well designed program structure. Global variables must not be used or large point penalties will be applied. All of the above emphasizes good program structure, design, and very basic, fundamental software engineering principles. Start by working on a good design, structure chart, etc. Recitation meetings will be an excellent source of help with this.


Use Of Data Structures and Data Types


You are required to use anarray of structsas the major data structure on this project with each struct as specified earlier in this write-up. Use the C++ string class to store and manipulate string data. Use thetypedefconstruct to both create and work with your array of structs type.


You will only have one array of structs declared in this program. You do not need any other arrays to complete the task as specified (with the exception of the C++ string class objects discussedabove,whichbynature,containarraysastheirclassmemberdata).Youmaynotuseany two-dimensional arrays, dynamic arrays, or user-defined classes on this project. You also


3


may not usethe C++ Standard Template Library classes or algorithms, with the exception of the C++ string class as described here, and the standard basic iostream classes as discussed in this course.


These are the user files.


10


abc123


chocolat


1234


gqu456


dog


4321


a8b9c1


catdog


8765


jrj101


cinnamon


9090


hyg34m


karate


1001


w3r4t5


biscuit


6723


mnbvcx


wireless


1111


1a1b1c


mouse


1987


jkl789


flkeys


5665


4n5m67


ata


3456




Answered Same DayApr 20, 2021

Answer To: Programming Assignment 6: Web Site Login COP XXXXXXXXXXSpring Term 2020 Point Value: 100 points...

Shivani answered on Apr 20 2021
129 Votes
#include
#include
#include
#include
#include
u
sing namespace std;
// struct to store user's record
struct UserRecord
{
string userID;
string password;
int PIN;
};
int main()
{
    typedef struct UserRecord users;
    users arr_users[50];
    
    int num_users=0, itr=0, num_attempts=0;
    string userid, userpassword;
    int userpin;
    
    // Opening the .txt
    string fname = "users.txt";
    ifstream users_file;
    users_file.open(fname);
    
    // Reading the file and printing the data to std output
    users_file >> num_users;
    cout << endl...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here