Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

REQUIREMENTS: You will define a new function to encrypt the user's password for their account, accepting one argument, the password string in plaintext, and

 
 
 

student submitted image, transcription available belowstudent submitted image, transcription available belowstudent submitted image, transcription available belowstudent submitted image, transcription available below

 
 

REQUIREMENTS: You will define a new function to encrypt the user's password for their account, accepting one argument, the password string in plaintext, and returning the encrypted password string. You will use the substitution cipher called the Caesar cipher to replace each letter or digit by three positions down. For example, the uppercase letter 'A' would be replaced by the uppercase letter 'D', the uppercase letter 'B' would be replaced by the uppercase letter 'E', and so on. However, note that the uppercase letter 'X' would be replaced by the uppercase letter 'A', since it would wrap around the alphabet, and so forth. Similarly, the lowercase 'a' would be replaced by a lowercase 'd', and so forth, also wrapping around the alphabet for the lowercase letters 'x', 'y', and 'z'. Also, the digit '0' would be replaced by the digit '3', the digit '1' would be replaced by the digit '4', and so forth. Also, the digit '7' would be replaced by the digit '0', since it would wrap around to the start of the digits, and so forth. Any character that is not an upper- or lowercase letter or digit, such as the '@' or '%', should not be modified and left as is. o To help with the encryption, you are recommended to make use of their ASCII values. For example, the uppercase 'A' starts the uppercase letters and has an ASCII value of 65. To do the shift hree characters, you can make use of the following formula (modifying to fit your needs) for uppercase letters: c = (m + 3- 65) % 26 + 65 where c is the ciphertext and m is the plaintext uppercase letter. This formula takes into account the wrap around that would occur for the last three uppercase letters, but you should also make use of the chr () and ord () functions as necessary. You will have to modify this formula for the lowercase letters and digits as appropriate. You will define a new function to deposit an amount to the account balance, accepting one argument, the deposit amount as a floating-point number. In this function, you will simply add the deposit amount to the current balance in the account and print the new balance. There is no return statement for this function. You will define a new function to withdraw an amount from the account balance, accepting one argument, the withdrawal amount as a floating-point number. In this function, if the current balance in the account is greater than or equal to the withdrawal amount, you will deduct the amount from the balance and print the new balance. If the amount is greater than the current balance in the account, you will print a message that the transaction is denied due to insufficient funds. There is no return statement for this function. As with all homework programs in this course, your program's output initially displays the department and course number, your name, your EUID, and your email address. This means that your program will print this information to the terminal (see SAMPLE OUTPUT). You will use a dictionary (i.e., Python dictionary) to hold the account information that includes the user ID, password, and account balance. You will also keep track of whether or not the user has logged in (i.e., been authenticated) to their account as services may not be accessed until the user has logged in (except a hidden option described below). After the account is initially opened, the user will not be logged in to their account. Before displaying the menu option, you will allow the user to "open" their account with the following: 1. You will prompt for and read in a new user ID and password for the new account as a string for each of these values. Before storing the password in the dictionary, you will first encrypt the password using the user-defined encryption function defined above. 2. You will then prompt for and read in the initial balance associated with the new account as a floating-point number. Inside a loop, your program will continuously display a menu with the following account options until the user decides to exit/logout of the program: Select a service: 1. Login to Account. 2. Deposit to Account 3. Withdraw from Account 4. Print Balance. 5. Change Password. 6. Exit/Logout You may assume that the user enters an integer in response to this menu, although the integer may be out of range. If the user selection is not valid, you will print out an appropriate message that the selection is invalid and continue to display the menu and re-prompt the user to enter a value until a valid value is entered. User menu selection input: 1. Upon selection of the Login to Account option, you will prompt for and read in the user ID and password as a string for each of these values. Then, you will compare the user ID and password just entered with the values stored in the account (i.e., in the dictionary), remembering that the stored password has been encrypted. If the user ID and password match, you will then mark the user as authenticated (i.e., logged in) and print an appropriate status message. If these values do not match, you will print out an appropriate message that the user was not able to be logged in due to an invalid user ID or password. 2. Upon selection of the Deposit to Account option, if the user has been authenticated, you will prompt for and read in the deposit amount as a floating-point number and then call the deposit function defined above to deposit the amount just entered. If the user has not been authenticated, you will print out an appropriate message that their transaction could not be performed since the user is not logged in. 3. Upon selection of the Withdraw from Account option, if the user has been authenticated, you will prompt for and read in the withdrawal amount as a floating-point number and then call the withdraw function defined above to withdraw the amount just entered. If the user has not been authenticated, you will print out an appropriate message that their transaction could not be performed since the user is not logged in. 4. Upon selection of the Print Balance option, if the user has been authenticated, you will simply print out the current account balance for the user's account. If the user has not been authenticated, you will print out an appropriate message that their transaction could not be performed since the user is not logged in. 5. Upon selection of the Change Password option, if the user has been authenticated, you will prompt for and read in the new password as a string and then encrypt and update the encrypted password stored in the account. If the user has not been authenticated, you will print out an appropriate message that their transaction could not be performed since the user is not logged in. 6. Upon selection of the Exit/Logout option, you will print out an appropriate message that the user has logged out of their account and exit the loop/program. 9. There is a hidden number '9' option that is not displayed in the menu, but prints out the account information in the dictionary whether the user is logged in or not. All balances should be properly displayed, formatted to two decimal places. Your code should be well documented in terms of comments. For example, good comments in general consist of a header (with your name, course section, date, and brief description), comments for each variable, and commented blocks of code. This means that in addition to the program printing your information to the terminal (see SAMPLE OUTPUT), some of this information will also appear in the code in the comments as well. Your program source code should be named "assignment2.py", without the quotes. Your program will be graded based largely on whether it works correctly on our Linux CSE machines (e.g., cse01, cse02, ..., cse06), so you should make sure that your program runs on a CSE machine. This is an individual programming assignment that must be the sole work of the individual student. You may assume that all input will be of the appropriate data type, but may be out of range. You shall use techniques and concepts discussed in class - you are not to use any items specifically not recommended in this class. DESIGN (ALGORITHM): On a piece of paper (or word processor), write down the algorithm, or sequence of steps, that you will use to solve the problem. You may think of this as a "recipe" for someone else to follow. Continue to refine your "recipe" until it is clear and deterministically solves the problem. Be sure to include the steps for prompting for input, performing calculations, and displaying output. You should attempt to solve the problem by hand first (using a calculator as needed) to work out what the answer should be for a few sets of inputs. Type these steps and calculations into a document (i.e., Word, text, PDF) that will be submitted along with your source code. Note that if you do any work by hand, images (such as pictures) may be used, but they must be clear and easily readable. This document shall contain both the algorithm and any supporting hand-calculations you used in verifying your results. SAMPLE OUTPUT (input shown in bold): $ python3 assignment2.py Computer Science and Engineering CSCE 1035 Computer Programming I Student Name EUID euid@my.unt.edu Enter new user ID : wdj0017 Enter password : P@55W0rd$ Enter initial balance: $100.27 I I +

Step by Step Solution

3.36 Rating (165 Votes )

There are 3 Steps involved in it

Step: 1

Here is the Python code that implements the requirements you provided python Department and Course Number printCSCE 1030 Introduction to Computer Science Your Name EUID and Email Address printJohn Doe ... blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Microeconomics An Intuitive Approach with Calculus

Authors: Thomas Nechyba

1st edition

538453257, 978-0538453257

More Books

Students also viewed these Programming questions

Question

Define positive thinking and negative thinking. (pp. 170, 172)

Answered: 1 week ago