Home ] Up ] Syllabus ] Resources ] Tools ] Announcement ] Code ]

Assignment 1 -- Fall 2007

Due date: September 13, 2007.

Points: 4 points

You may run a sample solution for assignment 1 to see how it behaviors hosted on SOMEE.

Any delay of each day after the deadline will costs you 0.3 point

Description of assignment:

 

You are asked to build a simple wage calculator page.

Consultants will be asked to enter their profiles including:

  • Whether they have a MCSD certificate?
  • How many hours they have worked for the week?
  • and their job title. 

Possible job titles are: Programmer, Analyst, Architect, and Project Lead.

You should calculate their weekly wage based on the following information and rules:

  1. The base hourly rate for various titles are determined as the following:  
  • Programmer - $40
  • Analyst - $50
  • Architect - $60
  • Project Lead - $70 

     You should use the ITEMS property of the radiobuttonlist to set up these 4 items  For each item, the text property should be the title of the job and the value property should be the dollar amount without the $. 

  1. If a person has the MCSD certification, his or her base rate will be 10% more than normal base rate specified in Item 1 above.    (1 point)
  2. If a person works for more than 40 hours a week, any hours beyond the 40 hours should be counted as overtime, and will be paid 50% more than the base rate (i.e., 1.5 ratio of the base rate).  (1.5 points)

Additional requirements (The ADD.aspx example discussed in class in the first set of the PPT slides can help you to fulfilled these requirements):

  1. Check to make sure that the hours enter is a number and a number between 0 to 80.  Give the use a proper error message if an error occurs.  (1 points)
  2. Display the estimated wage in currency format. (0.5 point)

Submission requirement: 

  1. Post your assignment to a hosting site and send the link to me by email.   You should set up a free hosting account for ASP.NET 2.0
  2. If you really have trouble for setting the hosting account, you could submit by email to me. 

 

Code sample for data type conversion, exceptional handling, error checking, and currency formatting. 
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
       	Dim h As Single
        Try
            h = CType(TextBox1.Text, Single)
             
            If h >= 0 And h <= 80 Then
                ' Calculate the Wage 
                ' and display the result via a label's text property 
            Else
                Label1.Text = "You need to enter an integer from 1 to 80."
            End If
        Catch ex As Exception
            Label1.Text = "You did not enter an integer for the number of hours worked this week"
        End Try
    End Sub

Common errors for single file format.  

  • If use code behind, then you have to upload your assignment1.aspx and assignment1.pasx.vb to the hosting site. 
  • When you use the single file format (inline coding),  if you double click a control such as Checkbox1 by an accident, you need to delete the generated event handling procedure placed in the <script> session.

Protected Sub CheckBox1_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs)

End Sub

You should delete the attribute OnCheckedChanged (or other OnXXXX attribute for another Web server control) in the Web server control tag as illustrated below.

<asp:CheckBox ID="CheckBox1" runat="server" Text="I have a MCSD Certificate" OnCheckedChanged="CheckBox1_CheckedChanged" /><br />

  • All your code should be associated with the click event of the button on your web form.

==

Partial Code for your reference 

' comments --- are comments in VB.NET

==

<script runat="server">

Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs)

Dim rate, adjustRate, wage, hours As Single

' Check to see whether the Textbox1.Text is number and between 0-80

Try

' Convert Textbox1.Text to hours

' Check the hours is between 0-80

' If out of rage, give proper error message to the user via Label1

' and Exit Sub

Catch ex As Exception

' Set Label1.Text with proper error message

Exit Sub

End Try

' If no error convert the hours into a local variable with single precision data type

' Adjust the basic rate by 1.1 time if the person has MCSD certification

rate = RadioButtonList1.SelectedValue

If CheckBox1.Checked Then

    adjustRate = rate * 1.1

Else

    adjustRate = rate

End If

' calculate wage by considering over time charge

' Print the result in currency format via Label1

End Sub

</script>