Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Chapter 4 Creating Your First C# Application (Combined Lab and Programming Assignment #1) This first lab is both a lab and first programming assignment. Well

Chapter 4 Creating Your First C# Application (Combined Lab and Programming Assignment #1) This first lab is both a lab and first programming assignment. Well start it in class but youll need to complete it on your own if youre unable to complete it during class. Youll create a project that will redo the Sunshine Cellular example from chapter 3 of your MIS 221 textbook. Although it doesnt exercise every type of declaration or arithmetic operator, it should provide a relatively easy program to get your first experience in C# Create a new C# project called Yourname1 (Mine would be called Hawk1). This naming convention will help me when I look at any of your projects to know (a) who its from, and (b) which programming assignment it is for - program 1 in this case. After selecting New / Project from the file menu, you should get a form similar to whats shown below. Before clicking OK: 1. Select the language of the project to be C#. 2. It should by default indicate that youre creating a Windows Form Application. If not, make the selection as shown below. 3. Select the location of the project. Placing it in your network directory or on a flash drive is best. Placing it on the C: drive of a computer in the lab isnt recommended since it could be found by someone who uses that computer after you. If youre using your own computer this doesnt matter. An obvious point is to remember where you put it so you can find it later. 4. Give the Project the proper name (Hawk1 below) 5. Make sure the Create directory for solution checkbox is deselected. After clicking OK, youll have your initial project with a blank Form1. The following shows how you should modify Form 1. Besides the Form title and the four informative labels, add the following controls using the names specified. Resize and position the controls on the form so it looks good trying to reproduce my design is fine but not required: txtSilver a text box with a silver background txtBlue a text box with a sky blue background lblTotalPhones a label where you set AutoSize to false and place a border around it lblTotalPrice - a label where you set AutoSize to false and place a border around it. btnCalc a button that says Calculate Order btnClear a button that says Clear Screen btnExit a button that says Exit Create three button click methods. The following shows the Visual Basic code from the Sunshine Cellular project. Create a click event method (or procedure) for each of the button click events by rewriting the VB code using C#. Other than changing the names of controls to be consistent with widely accepted standards for control names, the code shown below is almost identical to the example from your MIS 221 textbook. Chapter 4 from your current textbook (and my PowerPoint notes) gives you almost all the details on how to implement each of the VB statements in C#. Comments can be inserted using // instead of the single quote mark '. The btnCalc_Click method. ' calculates the total number of phones ' ordered and the total price ' declare constants and variables Const PhonePrice As Decimal = 100D Const TaxRate As Decimal = 0.05D Dim silverPhones As Integer Dim bluePhones As Integer Dim totalPhones As Integer Dim subtotal As Decimal Dim salesTax As Decimal Dim totalPrice As Decimal ' assign user input to variables Integer.TryParse(txtSilver.Text, silverPhones) Integer.TryParse(txtBlue.Text, bluePhones) ' perform calculations totalPhones = silverPhones + bluePhones subtotal = totalPhones * PhonePrice salesTax = subtotal * TaxRate totalPrice = subtotal + salesTax ' display calculated amounts lblTotalPhones.Text = Convert.ToString(totalPhones) lblTotalPrice.Text = totalPrice.ToString("C2") The btnExit_Click method. Me.Close() The btnClear_Click method. - The following blanks out the text boxes and the two output labels. ' prepares the screen for the next order txtSilver.Text = "" ' You also can use String.Empty instead of "", txtBlue.Text = "" ' the same as you did in MIS 221. lblTotalPhones.Text = "" lblTotalPrice.Text = ""

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

Database Processing

Authors: David M. Kroenke

12th Edition International Edition

1292023422, 978-1292023427

More Books

Students also viewed these Databases questions

Question

Draw and explain the operation of LVDT for pressure measurement

Answered: 1 week ago