Buzz Flower Shop Lab2

Buzz Flower Shop Lab2 - 1 Buzz Flower Shop ‐ Lab 2 In...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: 1 Buzz Flower Shop ‐ Lab 2 In this lab assignment, you will create an application that calculates total sales amount for Buzz Flower Shop and also computes the flower price considering discount rate and tax rate. Topics covered in this lab assignment: • • • Familiarize yourself with variables, named constants, static variables, and variable scope Use of arithmetic operators Use of Option statement, String formatter Setting up Your Project: • • • • • First, download the file Lab2‐Variables‐student.zip from Bb to a folder in your computer. Uncompress the downloaded file. 1. In the folder Lab2‐Variables‐student, You should be able to see the solution file Lab2‐ 0101‐Hello‐World and the folder Lab2‐0101‐Hello‐World Open the solution Lab2‐0101‐Hello‐World by double‐clicking the solution file Lab2‐0101‐Hello‐ World in the directory. (Visual Studio will start automatically.) 1. In Solution Explorer, change the Project File property value From: Lab2‐0101‐Hello‐World.vbproj To: Lab2‐Section‐YourFirstName‐YourLastName.vbproj For example, if you are in section 0101 and your first name is Peng and last name is Huang, the project name will be Lab2‐0101‐Peng‐Huang 2. Double‐click Lab2.vb in Solution Explorer to load Form Designer on your screen. Basic form is already designed for you and you will modify the design for this lab assignment. Click the Save All menu item under File menu. Close Visual Studio and try to reopen your project by double clicking the solution file. Verify that your project can be loaded without any problem. Application Requirements: • Design a form that is similar to Figure 1. See the control description below. (See also Table 1) 1. A label to show the text Total Sales Amount in the form. (See Figure 1.) 2. A read‐only TextBox to show the total sales amount (name: totalSalesTextBox) 3. A TextBox to get the discount percent (name: discountRateTextBox) Initial value should be set to 5.0 Text should be right‐aligned. 4. A Button to add the extended price to the total sales amount. Use the name addToOrderButton. Clicking this button will add the extended price to the total sales amount. BMGT302 Lab 2 2 Figure 1 ‐ Form Design Table 1 ‐ Control Information (Include only new controls in this assignment) Type Label TextBox TextBox Button Name totalSalesLabel discountRateTextBox totalSalesTextBox addToOrderButton Displayed text Total Sales Amount 5.0 Add to Order Properties Right‐aligned Read‐Only Access Key: Alt+ a • Tab order should be set as show in Figure 2. To see tab orders, use the menu item Tab Order under the View menu, after clicking the form itself in the form designer window. Figure 2 – Tab Order BMGT302 Lab 2 • 3 Declare variables considering the variable properties in Table 2. Table 2 Variable Properties Variable name TaxRate TulipPrice DaisyPrice RosePrice discountRate discountedPrice extendedPrice tax totalSales Scope Class Class Class Class Procedure Class Class Procedure Procedure Type Double Double Double Double Double Double Double Double Double Static Double Constness Yes Yes Yes Yes No No No No No Remarks Initial value: 0.06 29.99 19.99 39.99 In calcButton_Click procedure In calcButton_Click procedure In addToOrderButton_Click procedure price Class No • Make the ‘Calculate’ Button the AcceptButton of the form. • In the code editor, include following comments in your code at the top of the Lab2.vb code. (Above the line Public Class Lab2.) ‘Project: Lab2 ‘Written by: Your full name ‘Date: today’s date • In the code editor, include following statements in the General Declaration Section. (Above the line Public Class Lab2 and below the lines for the comments in the previous bullet) After completing this assignment, you can try with different combinations of this option values to see effect of each option. Option Explicit On Option Infer Off Option Strict On • TOE (Task‐Object‐Event) chart is given in Table 3. Implement your code to accomplish the task described in the table. You may need to add more statements in the source code given already, or need to create new procedures. 1. For the tasks in the shaded rows of the table, there are procedures partially coded in the source code. Modify an appropriate event handling procedure for each task. 2. To convert the text in a TextBox to a numeric variable, use TryParse method. 3. To show value in priceTextBox and totalSalesTextBox, use discountedPrice.ToString and totalSales.ToString with C2 formatting option. BMGT302 Lab 2 4 4. To disable a button, set the “Enabled” property of the button to False. Set it to True if you want to enable it. 5. To edit the event handler of the Form Load event, double click on the GUI of the form to bring up the template of the event handler “MyBase.Load”. Table 3 Task Object Event chart Task Display tulip photo in photoPictureBox and show tulip price in priceTextBox ‐ set the value of the class‐level variable ‘price’ to tulipPrice ‐ show the tulip price in the priceTextBox ‐ clear text in discountedPriceTextBox and extendedPriceTextBox Disable addToOrderButton Display daisy photo in photoPictureBox and show daisy price in priceTextBox ‐ set the value of the class‐level variable ‘price’ to daisyPrice ‐ show the daisy price in the priceTextBox ‐ clear text in discountedPriceTextBox and extendedPriceTextBox Disable addToOrderButton Display rose photo of rosePictureBox and show rose price in priceTextBox ‐ set the value of the class‐level variable ‘price’ to rosePrice ‐ show the rose price in the priceTextBox ‐ clear text in discountedPriceTextBox and extendedPriceTextBox Disable addToOrderButton Calculate and show discounted price and extended price of the selected flower Enable addToOrderButton Update total sales amount. ‐ Add sales amount in extendedPriceTextBox to totalSales and display totalSales in totalSalesTextBox ‐ Move focus to discountRateTextBox Display tulip photo in photoPictureBox and show tulip price in priceTextBox ‐ set the value of the class‐level variable ‘price’ to tulipPrice Disable addToOrderButton BMGT302 Lab 2 Object tulipButton Event Click, Alt+t daisyButton Click, Alt+d roseButton Click, Alt+r calcButton Click, Alt+c addToOrderButton Click, Alt+f Lab2 Form At Form load 5 • • Pseudo‐code for calcButton_Click event procedure 1. Assign discount rate user input to discountRate variable 2. Discounted price = (1 ‐ discountRate/100) * price 3. tax = tax rate * discounted price 4. Extended price = discounted price + tax 5. Display the discounted price in discountedPriceTextBox. 6. Display the extended price in extendedPriceTextBox Pseudo‐code for addToOrderButton_Click event procedure 1. totalSales = totalSales + extended price 2. Display total sales in totalSalesTextBox. Test Your Application: • Test your application to ensure that it works as intended, considering the application requirements. After You Completed: • • • Before you close your project, save everything first. (Click Save All menu item under File menu.) Close Visual Studio. (Click the Exit menu item under File menu.) Locate the folder that contains your project using Windows File Explorer and copy the folder into your USB drive for your record. BMGT302 Lab 2 ...
View Full Document

{[ snackBarMessage ]}

Ask a homework question - tutors are online