Question

Suppose a number is used in calculations throughout a program and must be changed every few...

Suppose a number is used in calculations throughout a program and must be changed every few months. What benefit is there to using a named constant to represent the number?

List and explain two Visual Basic selection statements. Provide at least one original example for each statement you list.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Benefits of using a named constant:

The value cannot be changed anywhere in the programming code.

It is easier to make widespread changes anywhere in the codes.

Code looks very neat and memory consumption is reduced.

VB selection statements:

1) If statement

Module decisions
   Sub Main()
       'local variable definition '
      Dim num As Integer = 10

      ' check the boolean condition using if statement 
      If (num >=0) Then
          ' if condition is true then print the following 
          Console.WriteLine("Number is greater than or equal to zero")
      Else
          ' if condition is false then print the following 
          Console.WriteLine("NUmber is less than zero")
      Console.ReadLine()
   End Sub
End Module

2) Switch statement

Module decisions
   Sub Main()
      'local variable definition
      Dim grade As Char
      gradeSystem = "C"
      Select gradeSystem
          Case "A"
              Console.WriteLine("Superb perfomance!")
          Case "B", "C"
              Console.WriteLine("Well done this great work")
          Case "D"
              Console.WriteLine("You have passed")
          Case "F"
              Console.WriteLine("PLease try again")
          Case Else
              Console.WriteLine("You have entered an invalid grade ")
      End Select
      Console.WriteLine("Your grade is  {0}", grade)
      Console.ReadLine()
   End Sub
End Module

Please rate it if the above solution helps you in any way or if you have any concerns comment it, I will help you through again.

Add a comment
Know the answer?
Add Answer to:
Suppose a number is used in calculations throughout a program and must be changed every few...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT