Lab 3 Solution

$35.00 $29.05

You'll get a: . zip file solution, download link after Payment

Category: Tag:

Description

Each lab will begin with a recap of last lab and a brief demonstration by the TAs for the core concepts examined in this lab. As such, this document will not serve to tell you everything the TAs will in the demo. It is highly encouraged that you ask questions and take notes. In order to get credit for the lab, you need to be checked off by the end of lab. For non-zero labs, you can earn a maximum of 3 points for lab work completed outside of lab time, but you must finish the lab before the next lab. For extenuating circumstance, contact your lab TAs and Instructor.

(2 pts) Demo: Loops

Following along with your TA as they walk you through for loops, while loops and do while loops. You will also learn how to kill a runaway loop (infinite loop).

(2 pts) Design

Design is very important when developing programs and there are a variety of ways to approach it. You may draw pictures, write it out in prose or structured text, use pseudo code, and more! The point of design is to give you a blueprint to follow while you are coding. This saves time debugging your program as you can catch mistakes early. It is better to spend one hour of designing than it is to spend five hours debugging.

For this lab you must design a solution to the following problem statement. You will implement your solution.

Problem Statement

A good password has many requirements. Humans have a hard time meeting these requirements left to their own devices. You are tasked with creating a program that will generate a password based on what the user wants in the password.

The user should be able to choose if they want a password with:

*letters

*upper case

*lower case

*numbers

The user should also provide the length of the password and how much of the password should be comprised of their selections. You can generate in order or out of order (see below).

For example:

lu57406v4v tmp 56d09a6910c8f90e

Welcome to Password Creator!

How long do you want the password to be? 10

Do you want letters (0-no, 1-yes)? 1

Do you want uppercase letters (0-no, 1-yes)? 1

How many characters of the password should be uppercase? 2

Do you want lowercase letters (0-no, 1-yes)? 1

How many characters of the password should be lowercase? 4

Do you want numbers (0-no, 1-yes)? 1

How many characters of the password should be numbers? 4

Your random password is: ACbzdf1254 or AtCde1z254 (either would be acceptable passwords)

Would you like to create another password (0-no, 1-yes)? 0

lu57406v4v tmp 56d09a6910c8f90e

You need to generate characters and numbers for the password length specified by the user. Therefore, you need a way to repeat generating random numbers and characters. You could use a while loop, but it would be more appropriate to use a for loop. For example:

for(int i=0; i<pass_length; i++) {

//write code you want repeated inside here

}

(4 pts) Implementation

Your design must be checked off by a TA before proceeding to code.

In your implementation, you must use the ASCII chart, and you must use rand and srand to generate random values. Think about how we used rand to get a range of numbers in class.

Notice characters and numbers are in ranges in the ASCII chart: http://www.asciitable.com/

(2 pts) Debug

Download the following file in your terminal using the following line:

wget http://classes.engr.oregonstate.edu/eecs/winter2018/cs161-001/labs/bug_hunt.cpp

There are four bugs: two logical, two syntactical. Find and fix all of them and present your solution to the TAs.