23.05.2017 Views

BIS 450 DeVry Week 3 I Lab 3

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

<strong>BIS</strong> <strong>450</strong> <strong>DeVry</strong> <strong>Week</strong> 3 I <strong>Lab</strong> 3<br />

Downloading is very simple, you can download this Course here:<br />

http://wiseamerican.us/product/bis-<strong>450</strong>-devry-week-3-ilab-3/<br />

Or<br />

Contact us at:<br />

SUPPORT@WISEAMERICAN.US<br />

<strong>BIS</strong> <strong>450</strong> <strong>DeVry</strong> <strong>Week</strong> 3 i<strong>Lab</strong> 3<br />

<strong>BIS</strong><strong>450</strong><br />

<strong>BIS</strong> <strong>450</strong> <strong>DeVry</strong> <strong>Week</strong> 3 i<strong>Lab</strong> 3<br />

i<strong>Lab</strong> 3 of 8: Daily Calorie Needs Calculator<br />

Submit your assignment to the Dropbox located on the silver tab at the top of this page.<br />

(See Syllabus/”Due Dates for Assignments & Exams” for due dates.)<br />

i L A B O V E R V I E W<br />

Scenario/Summary<br />

You have been asked to add a Daily Calorie Needs Calculator to the Healthy Eating website. This feature will determine<br />

how many calories an individual needs to consume daily to maintain his or her current body weight. If the person<br />

consumes fewer calories, he or she will lose weight; if more calories are consumed, the person will gain weight. Dr.<br />

Dinewell has provided you with the following specifications for the Daily Calorie Needs Calculator:<br />

• Inputs: Gender, weight (pounds), height (inches), age (years), activity level<br />

• Processing:<br />

o Basal Metabolic Rate (women) = 655 + (4.35*weight) + (4.7*height) – (4.7*age)<br />

o Basal Metabolic Rate (men) = 66 + (6.23 * weight) + (12.7*height) – (6.8*age)<br />

o Daily calorie needs = BMR * (activity factor)<br />

o Activity factor = 1.2 if sedentary, 1.375 if lightly active, 1.55 if moderately active, 1.725 if very active, 1.9 if extra active<br />

• Source: http://www.bmi-calculator.net/bmr-calculator/harris-benedict-equation/<br />

• Outputs: Daily calories needed to maintain current weight<br />

You will create an ASP.NET Web form to accept the user inputs and display the results. Because this is a more complex<br />

calculation involving more inputs than last week’s BMI Calculator, you will need to use several different types of server<br />

controls including radio buttons and a drop-down list for this task. You will also add input validation to ensure that the<br />

form will not malfunction or give erroneous results if some input values are missing or entered incorrectly.<br />

Deliverables<br />

1. Calorie Needs Calculator Web form (CalNeeds.aspx) and associated code-behind file (CalNeeds.aspx.vb) added to<br />

the Healthy Eating website on the <strong>DeVry</strong> Web server.<br />

2. Word document with three screenshots of Calorie Needs Calculator Web form displayed in browser (Your Name<br />

<strong>BIS</strong><strong>450</strong> <strong>Lab</strong>3 Screenshot.docx). Screen shots must show calculator test inputs and results or appropriate error<br />

messages. Screenshots must show the complete browser window, including the URL of the page.<br />

Grading Rubric


Criteria Points %<br />

Step 2: Create Calorie Needs Web Form (CalNeeds.aspx)<br />

• CalNeeds.aspx created in your Web folder<br />

• Has standard page header, navigation menu, and page footer<br />

• Form title “Calorie Needs Calculator” in bold<br />

• Input controls: radio buttons for male and female; textboxes for height, weight and age; drop-down list for activity level<br />

• Button for BMI calculation<br />

• Literal control below button for display of results 10 40%<br />

Step 3: Add Calculate BMI Event Handler in Code-Behind File (CalNeeds.aspx.vb)<br />

• Click event handler created for Calculate Calorie Needs button in code-behind file<br />

• Statement added to Else clause to calculate BMR for men using correct formula<br />

• Captures input values, calculates BMR, multiplies BMR by activity to calculate calories needed<br />

• Displays calories needed 6 24%<br />

Step 4: Add Input Validation (CalNeeds.aspx)<br />

• RequiredFieldValidators added for height, weight, and age<br />

• RangeValidator added to check height is 48-84 type Double<br />

• RangeValidator added to check weight is 50-500 type Double<br />

• RangeValidator added to check age is 18-120 type Integer<br />

• Appropriate error messages displayed by all validators 6 24%<br />

Step 5: Test, Capture Screen Shots, and Submit (Student Name <strong>BIS</strong><strong>450</strong> <strong>Lab</strong>3 Screenshot.docx)<br />

• Word file submitted to Dropbox with screen shots of:<br />

o Calculator with correct inputs (calories should be 2173)<br />

o Calculator with all fields blank (should display all required field error messages)<br />

o Calculator with invalid inputs (should display all range error messages) 3 12%<br />

Total 25 100%<br />

PREPARATION<br />

1. Download the file <strong>BIS</strong><strong>450</strong> <strong>Lab</strong>3 Code Snippets.txt from Doc Sharing and save it in your working folder for this lab.<br />

2. Using the Citrix remote lab:<br />

a. Follow the login instructions located in the i<strong>Lab</strong> tab in Course Home.<br />

b. Upload the file you downloaded from Doc Sharing into your <strong>BIS</strong><strong>450</strong><strong>Lab</strong>s folder on your Citrix drive (you created this<br />

folder in <strong>Week</strong> 1).<br />

STEP 1: Open Website on the <strong>DeVry</strong> Web Server<br />

1. Launch Microsoft Visual Studio 2010.<br />

You must use Visual Studio 2010 in the Citrix environment.<br />

2. Pull down the File menu and select Open, then select Web Site. In the Open Web Site dialog, select FTP Site in the<br />

left column. The connection information you used in the previous lab should be displayed:<br />

• Server: bisweb.devry.edu


• Port: 21<br />

• Directory: coursefolder/yourname, where coursefolder = folder on the web server for your course (provided by your<br />

professor), and yourname = your first initial and last name, (for example, jsmith for student John Smith).<br />

• Passive Mode and Anonymous Login: Both unchecked.<br />

• Username: acadDnnnnnnnn, where Dnnnnnnnn = your DSI number.<br />

• Password: Enter the same password as you use for Citrix i<strong>Lab</strong> (must be re-entered each time).<br />

Click Open.<br />

STEP 2: Create Calorie Needs Web Form<br />

1. Add a new Web form named CalNeeds.aspx to the site. (Review last week’s i<strong>Lab</strong> if you need help remembering<br />

exactly how to do this.)<br />

2. Set the Title property of the Document to Calorie Needs Calculator.<br />

3. Attach StyleSheet.css to the Web form.<br />

4. As you did when setting up the BMI Calculator Web form in last week’s i<strong>Lab</strong>, open Default.htm and copy the contents<br />

of its element (in HTML, everything in between the and tags, but not the and tags themselves). Paste these contents<br />

inside the div in CalNeeds.aspx (in HTML, in between the<br />

and<br />

tags). Delete the contents of the #main div after pasting.<br />

5. Inside div#main, type Daily Calorie Needs Calculator as a heading for the form, followed by a blank line. Bold this<br />

heading.<br />

6. Type the following input prompts, one per line with a blank line between each, and add the corresponding control<br />

from the Standard section of the Toolbox after each prompt. Set the properties of each control as indicated below.<br />

Prompt Control (ID) Text<br />

Gender: RadioButton<br />

RadioButton rdoFemale<br />

rdoMale Female<br />

Male<br />

Height (inches): TextBox txtHeight<br />

Weight (pounds): TextBox txtWeight<br />

Age (years): TextBox txtAge<br />

Activity Level: DropDownList ddlActivity<br />

7. For each of the two RadioButtons, set the GroupName property to Gender. (Giving both RadioButtons the same<br />

GroupName ensures that only one can be “on” at a time.) Also, set the Checked property of the rdoFemale RadioButton<br />

to True (Female will be the default).<br />

8. Select the ddlActivity DropDownList control, click the Items property in the Properties pane, and then click on the<br />

button with three dots […] that appears. In the ListItem Collection Editor dialog, click Add. Enter Sedentary (little or no<br />

exercise) as the Text and 1.2 as the Value, and set Selected to True.<br />

Continue clicking Add to add the following items to the list:<br />

Text Value Selected<br />

Lightly active (1-3 days/week) 1.375 False<br />

Moderately active (3-5 days/week) 1.55 False


Very active (6-7 days/week) 1.725 False<br />

Extra active (sports & physical job) 1.9 False<br />

The completed list should look like the following:<br />

After you have finished adding items to the list, click OK.<br />

9. Below the Activity Level input, insert a blank line and place the following additional controls, with a blank line between<br />

each one, setting properties as indicated:<br />

Control (ID) Text<br />

Button btnCalculate Calculate Calorie Needs<br />

Literal litResults<br />

Your completed Web form should look like the following in Design View:<br />

10. Save the Web form.<br />

STEP 3: Add Calculate Calorie Needs Event Handler in Code-Behind File<br />

1. Double-click the btnCalculate button to create a skeleton click event handler procedure in the code-behind file.<br />

2. Open the <strong>BIS</strong><strong>450</strong> <strong>Lab</strong>3 Code Snippets.txt file that you downloaded from Doc Sharing, select and copy the section of<br />

code beginning with the comment “‘Calculate daily calorie needs”, and paste it in between the Protected Sub<br />

btnCalculate_Click(. . . ) and End Sub statements in the code-behind file. Notice that the code is incomplete. After<br />

pasting in this code, the code-behind file should look like this:<br />

3. Based on the specifications provided by Dr. Dinewell (listed in the scenario at the top of these lab instructions), write<br />

the additional statement needed in the Else clause to calculate the BMR for men. Use the formula for women provided<br />

in the function as a model.<br />

Hint: You only need to replace the “‘TO DO:” line with the men’s BMR values.<br />

4. Save your work so far.<br />

STEP 4: Add Input Validation<br />

1. Return to editing the CalNeeds.aspx Web form in Design View.<br />

2. Drag a RequiredFieldValidator control from the Validation section of the Toolbox and place it on the form just to the<br />

right of the txtHeight TextBox. Set its properties as follows to ensure that the user enters a value for height:<br />

Property Setting<br />

ControlToValidate txtHeight<br />

Display Dynamic<br />

ErrorMessage You must enter your height in inches.<br />

3. Drag a RangeValidator control from the Validation section of the Toolbox and place it on the form to the right of the<br />

RequiredFieldValidator you added in the previous action. (It’s OK if the validators wrap onto the next line in the editing<br />

window display.) Set the RangeValidator’s properties as follows to ensure that the user enters a height value that is a<br />

type Double (that is, a decimal number,) that is in the range of 48 to 84 inches:<br />

Property Setting<br />

ControlToValidate txtHeight<br />

Display Dynamic<br />

ErrorMessage Height must be a decimal number between 48 and 84 inches.<br />

MaximumValue 84<br />

MinimumValue 48


Type Double<br />

Here is what part of your form should look like with both validation controls in place (what you see may vary depending<br />

on the width of your editing window):<br />

4. In a similar way, place a RequiredFieldValidator and a RangeValidator to the right of the txtWeight TextBox, and set<br />

their properties to ensure that the user enters a value for weight, and that value is a type Double (decimal number) that<br />

is between 50 pounds and 500 pounds. Compose your own reasonable error messages for these validators.<br />

5. Place a RequiredFieldValidator and a RangeValidator to the right of the txtAge TextBox, and set their properties to<br />

ensure that the user enters a value for age, and that value is a type Integer (whole number) that is between 18 and<br />

120. Compose your own reasonable error messages for these validators.<br />

6. Save your work.<br />

STEP 5: Test, Capture Screenshot, and Submit<br />

1. To test the Calorie Needs calculator, in the Solution Explorer window, right-click on CalNeeds.aspx and select View<br />

in Browser. If you experience problems viewing your page, perform the following:<br />

• In the Solution Explorer, right-click on your FTP address and select Property Pages.<br />

• Under the Start Options tab, make sure the Base URL is set to include the full HTTP address listing (example only:<br />

HTTP://bisweb.devry.edu/YourCourseFolder/YourPersonalFolder).<br />

2. Enter some different values for the various inputs into the calculator, click Calculate Calorie Needs, and check the<br />

results. Some test values you might want to try are:<br />

Gender Height Weight Age Activity Calories<br />

Female 60 120 35 Sedentary 1553<br />

Female 66 150 47 Lightly Active 1921<br />

Male 72 165 24 Moderately Active 2860<br />

Male 68 144 54 Very Active 2518<br />

Male 76 180 32 Extra Active 3677<br />

Here is an example of what your form should look like with one set of inputs:<br />

3. You should also test that your input validation works correctly. Try leaving the height, weight, or age fields blank and<br />

verify that the correct error messages are displayed. Also try entering values that are too high or too low in these fields.<br />

Here is an example of what your form should look like with an invalid entry:<br />

4. Capture a screenshot of the calculator after you click the Calculate Calorie Needs button with the following inputs,<br />

and paste it into a Word document:<br />

Gender Height Weight Age Activity<br />

Female 62 135 28 Moderately Active<br />

5. Capture a second screen shot of the calculator after you click the Calculate Calorie Needs button with the height,<br />

weight, and age fields all blank, and paste it into the same Word document.<br />

6. Capture a third screen shot of the calculator after you click the Calculate Calorie Needs button with the following<br />

(invalid) values for height, weight, and age, and paste it into the same Word document.<br />

Height Weight Age<br />

42 600 50.5<br />

7. Save the Word document containing your three screenshots as Your Name <strong>BIS</strong><strong>450</strong> <strong>Lab</strong>3 Screenshot.docx. (Make<br />

sure that the browser URL is visible in all your screen shots.) Submit this file to the <strong>Week</strong> 3 i<strong>Lab</strong> Dropbox.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!