Code to Calculate Discount

Here to example of using loob with condition to calculate discount price.

Module Module1
Dim Action As Integer
Dim i As Integer
Dim price As Double
Dim discount As Double
Dim net As Double
Dim discount_percent As String

Sub Main()

Console.WriteLine(“Main Menu”)
Console.WriteLine(“1. Show the discount info”)
Console.WriteLine(“2. Calculate the Discount”)
Console.WriteLine(“3. Show all Discount”)
Console.WriteLine(“4. Exit”)
Console.WriteLine(“Choose your action”)

Action = Console.ReadLine

If (Action = 1) Then
Console.WriteLine(“[0-1000]   5%”)
Console.WriteLine(“[1001-5000]   10%”)
Console.WriteLine(“[> 5000]   15%”)

ElseIf (Action = 2) Then
Console.WriteLine(“Please Enter the price”)
price = Console.ReadLine()
If (price < 0) Then
Console.WriteLine(“You can not the Negative Number”)

ElseIf (price >= 0) And (price <= 1000) Then
discount = 0.05
discount_percent = discount * 100
Console.WriteLine(“Discount Percentage is ={0}”, discount_percent)

ElseIf (price >= 1001) And (price <= 5000) Then
discount = 0.1
discount_percent = discount * 100
Console.WriteLine(“Discount Percentage is ={0}”, discount_percent)

discount = 0.15
discount_percent = discount * 100
Console.WriteLine(“Discount Percentage is ={0}”, discount_percent)

End If

ElseIf (Action = 3) Then
Console.WriteLine(“The Price is={0}”, price)
Console.WriteLine(“The Percentage of Discount is={0}”, discount)
net = price * (1 – discount)

Console.WriteLine(“You have to pay={0}”, net)
ElseIf (Action = 4) Then
Console.WriteLine(“You Ente the wrong number”)

End If

Loop While (Action = 1) Or (Action = 2) Or (Action = 3)

End Sub

End Module


4 thoughts on “Code to Calculate Discount

  1. Hi! sorry for late to wish u on Happy New Year 2009

    May The Lord bless you
    and always keep you
    May heaven’s light shine
    I wish this all and so much more
    May all your dreams come true
    And a Happy New Year , too ..
    May you count your blessings, one by one And when totaled by the lot May you find all you’ve been given To be more than what you sought May your journeys be short, your burdens light May your spirit never grow old May all your clouds have silver linings And your rainbows pots of gold


Fill in your details below or click an icon to log in:


អ្នក​កំពុង​បញ្ចេញ​មតិ​ដោយ​ប្រើ​គណនី របស់​អ្នក​។ Log Out /  ផ្លាស់ប្តូរ )

Google+ photo

អ្នក​កំពុង​បញ្ចេញ​មតិ​ដោយ​ប្រើ​គណនី Google+ របស់​អ្នក​។ Log Out /  ផ្លាស់ប្តូរ )

រូប Twitter

អ្នក​កំពុង​បញ្ចេញ​មតិ​ដោយ​ប្រើ​គណនី Twitter របស់​អ្នក​។ Log Out /  ផ្លាស់ប្តូរ )

រូបថត Facebook

អ្នក​កំពុង​បញ្ចេញ​មតិ​ដោយ​ប្រើ​គណនី Facebook របស់​អ្នក​។ Log Out /  ផ្លាស់ប្តូរ )


កំពុង​ភ្ជាប់​ទៅ​កាន់ %s