23 May, 2011

Decision




1.            Determine whether a number is Positive/Negative/Zero number.

• If TextBox1.Text < 0 Then TextBox2.Text = “Negative"
• If TextBox1.Text = 0 Then TextBox2.Text = “Zero"
• If TextBox1.Text > 0 Then TextBox2.Text = “Positive"



2.            Determine whether a number is Odd/Even number.

Dim a As Integer
        a = TextBox1.Text
        If ((a Mod 2) = 0) Then
            MsgBox("Even")
        Else
            MsgBox("Odd")
        End If


3.            Determine whether a number is Multiple of 3/5.

If TextBox1.Text Mod 3 = 0 And TextBox1.Text Mod 5 > 0 Then
TextBox2.Text = "Multiple of 3"
ElseIf TextBox1.Text Mod 5 = 0 And TextBox1.Text Mod 3 > 0 Then
TextBox2.Text = "Multiple of 5"
ElseIf TextBox1.Text Mod 3 = 0 And TextBox1.Text Mod 5 = 0 Then
TextBox2.Text = "Both"
        End If


4.            Determine whether a company has made Profit or Loss from Cost and Revenue of the company.

If TextBox1.Text > TextBox2.Text Then
            TextBox3.Text = "PROFIT"
        Else : TextBox3.Text = "LOSS"
        End If


5.            Determine the minimum/maximum of two/three numbers.

If TextBox1.Text > TextBox2.Text And TextBox3.Text < TextBox1.Text Then
            TextBox4.Text = TextBox1.Text
ElseIf TextBox2.Text > TextBox1.Text And TextBox3.Text < TextBox2.Text Then
            TextBox4.Text = TextBox2.Text
        Else
            TextBox4.Text = TextBox3.Text
        End If
-----------------------------------------------
If TextBox1.Text < TextBox2.Text And TextBox3.Text > TextBox1.Text Then
            TextBox5.Text = TextBox1.Text
        ElseIf TextBox2.Text < TextBox1.Text And TextBox3.Text > TextBox2.Text Then
            TextBox5.Text = TextBox2.Text
        Else
            TextBox5.Text = TextBox3.Text
        End If


6.           Determine whether a student has failed or passed based on the total percentage marks obtained by the student. 30% marks need to be achieved by a student to pass. Marks of 5 subjects will be input and total marks of each subject will be 100.

TextBox6.Text = TextBox1.Text + +TextBox2.Text + +TextBox3.Text + +TextBox4.Text + +TextBox5.Text
        If TextBox1.Text < 30 Or TextBox2.Text < 30 Or TextBox3.Text < 30 Or TextBox4.Text < 3 Or TextBox5.Text < 30 Then
            TextBox6.Text = "FAIL"
        Else
            TextBox6.Text = "PASS"
        End If



7.            Calculate the total salary (with bonus) for an employee of an organization. The bonus will be calculated by the following criteria:
Salary                                    Bonus
>25000                                  40%
20000-25000                                   30%
<20000                                   20%

If TextBox1.Text >= 25000 Then
TextBox2.Text = TextBox1.Text + +TextBox1.Text * 0.4
ElseIf TextBox1.Text > 20000 And TextBox1.Text < 25000 Then
TextBox2.Text = TextBox1.Text + +TextBox1.Text * 0.3
ElseIf TextBox1.Text <= 20000 Then
TextBox2.Text = TextBox1.Text + +TextBox1.Text * 0.2
End If



8.            Calculate the discount gained on total purchase amount by a customer in a Super shop. The discount rate is determined by the following criteria:
     Total Purchase Amount             Discount
 >=5000                                                         15%
            2500-4999                                                    10%
      < 2500                                                  5%

If TextBox1.Text >= 5000 Then
TextBox2.Text = TextBox1.Text - TextBox1.Text * 0.15
ElseIf TextBox1.Text > 2500 Or TextBox1.Text <= 4999 Then
TextBox2.Text = TextBox1.Text - TextBox1.Text * 0.1
ElseIf TextBox1.Text <= 2500 Then
TextBox2.Text = TextBox1.Text - TextBox1.Text * 0.05
        End If


9.            Determine the grade of a student based on the total marks obtained in a subject. The grading criteria is given below:
Total Marks                       Grade
>=90                                               A
70-89                                   B
60-69                                   C
50-59                                   D
< 50                                    F

Dim a As Integer
        a = TextBox1.Text
        If a > 89 Then
            MsgBox("You have passed at Grade A")
        ElseIf a > 69 Then
            MsgBox("You have passed at Grade B")
        ElseIf a > 59 Then
            MsgBox("You have passed at Grade C")
        ElseIf a > 49 Then
            MsgBox("You have passed at Grade D")
        Else
            MsgBox("You have failed F")
        End If


10.        Calculate the total cost of CDs sold by a computer store. The computer store sells DVDs at 70 taka each for small orders or at 60 taka each for orders of 100 DVDs or more. 
Dim n, Tc As Integer
        n = TextBox1.Text
        If n >= 100 Then
            Tc = n * 60
            TextBox2.Text = Tc
        Else
            Tc = n * 70
            TextBox2.Text = Tc
        End If
11. Once User has entered Salary, Calculate and display:
Bonus (20% of Salary),Total Salary (Salary + Bonus)

Dim Salary As Integer
Salary = TextBox1.Text
Dim Bonus As Integer
Bonus = Salary * .2
TextBox2.Text = Bonus
Dim TSalary As Integer
TSalary = Salary + Bonus
TextBox3.Text = TSalary

12. Once User has entered Unit Price & Discount (%), Calculate and display: Discount Amount, Payable Amount (Unit Price – Discount Amount)

Dim Price As Integer
Price = TextBox1.Text
Dim D As Integer
D = TextBox2.Text
Dim Discount As Integer
Discount = (Price * D) / 100
TextBox3.Text = Discount
Dim Pay As Integer
Pay = Price – Discount
TextBox4.Text = Pay





0 comments:

Post a Comment