Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Problem 1 In this problem, you will solve the problem of converting a four-digit binary number to decimal. Create a flowchart using Raptor. Write Python

Problem 1

In this problem, you will solve the problem of converting a four-digit binary number to decimal.

Create a flowchart using Raptor.

Write Python code that solves the problem.

Test both the flowchart as well as the program. Make sure that it prompts for each digit of the input binary number, computes the decimal value correctly, and displays the result as specified. Debug your code as necessary until it complies with all requirements.

The Raptor flowchart and Python code should prompt for user input and display results exactly as given in the sample interactions below.

2.1 Sample Interaction

Enter leftmost digit: 1

Enter the next digit: 0

Enter the next digit: 1

Enter the rightmost digit: 0

The value is 10

Problem 2

Develop a program that reads in the name of a person and generates a user id and password for that person, presumably for some computer system.

3.1 Input and Output

Here are the details of the interaction.

The system first prompts for and reads in the first name of the person. The prompt should besimilar to the one given in Section 3.3.

The system then prompts for and reads in the last name of the person. The prompt should besimilar to the one given in Section 3.3.

The system then displays the persons name, user id, and password. The annotation should be similar to the one given in Section 3.3.

3.2 Restrictions and Rules

The first and last names will typically have capital and lower-case letters.

The user id is formed by picking the first letter of the first name followed by the entire last name, with all characters in lower-case, followed by the year, month, and day the user id was created. The year must be four characters (like 2017), and the month and day of the month 2 characters each (like 08 and 07).

The following Python code gives you the current year.

datetime.date.today().year For example, the statement print(datetime.date.today().year) should print 2017 on the screen this semester.

Similarly, datetime.date.today().month and datetime.date.today().day give the current month and day of the month. By doing some arithmetic on the year, month, and day of the month, you can get an 8-digit number that essentially is the integer equivalent of the last part of the user id. For example, if I am executing the code on 8 September, 2017 and the integer the program generates would be 20170908.

Once you get an integer of the above kind, you can convert it to a string representation before appending to the initial part of the user id. We have seen how to do this in lecture 5.

You have to put the following at the top of your Python code.

import datetime

The password is a string containing only digits. The number formed by the digits is a random number between

the 8-digit number formed by concatenating the year (4 digits), the month (2 digits), and the day of the month (2 digits). that is, (see how the user id is created) and

the constant 30001231.

Thus the integer is the same integer you set up for creating the user id. 30001231 is obviously a constant. Once have these two numbers in hand, you can generate a random number between (and including) the two by employing the following code.

random.randint(, )

For example, the code random.randint(4, 9)

printed 5 for me when I tried it just now.

Test the program well. Make sure that it prompts for the input , computes the profit, and displays the result as specified. Debug your code as necessary until it complies with all requirements.

The Python code should prompt for user input and display results as given in the sample interactions below.

3.3 Sample Interactions

Enter the first name of the user: Mary

Enter the last name of the user: Bennett

User id for Mary Bennett is mbennett20170913 and password is 26393111

please add comments for cord for my understande.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

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

Step: 3

blur-text-image

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

Beginning VB.NET Databases

Authors: Thearon Willis

1st Edition

1594864217, 978-1594864216

More Books

Students also viewed these Databases questions