Rewrite the code using a select case block

Assignment Help Programming Languages
Reference no: EM13752052

1. Determine whether the condition is true or false. Assume a = 2 and b = 3.
((a = b) Or Not (b < a)) And ((a < b) Or (b = a + 1))

2. Determine whether or not the two conditions are equivalent - that is, whether they will be true or false for exactly the same values of the variables appearing in them.
Not ((a = b) Or (a = c)); (a <> b) And (a <> c)

3. Determine the output displayed in the text box when the button is clicked. Assume the response is B
Private Sub btnDisplay_Click(...) Handles btnDisplay.Click
Dim letter As String
letter = InputBox("Enter A, B, or C.")
letter = letter.ToUpper
If letter = "A" Then
txtOutput.Text = "A, my name is Alice."
ElseIf letter = "B" Then
txtOutput.Text = "To be, or not to be."
ElseIf letter = "C" Then
txtOutput.Text = "Oh, say, can you see."
Else
txtOutput.Text = "Not a valid letter."
End If
End Sub

4. Identify the errors.
Private Sub btnDisplay_Click(...) Handles btnDisplay.Click
'Is your program correct?
Dim query, answer1, answer2 As String
query = "Are you sure everything in your program is correct?"
answer1 = InputBox(query)
answer1 = answer1.ToUpper.Substring(0, 1)
If answer1 = "N" Then
txtOutput.Text = "Don't patch bad code, rewrite it."
Else
query = "Does your program run correctly?"
answer2 = InputBox(query)
answer2 = answer2.ToUpper.Substring(0, 1)
If answer2 = "Y" Then
txtOutput.Text = "Congratulations."
Else
txtOutput.Text = "Something you are sure about is wrong."
End If
End Sub

5. The current calendar, called the Gregorian calendar, was introduced in 1582. Every year divisible by four was declared to be a leap year, with the exception of the years ending in 00 (that is those divisible by 100) and not divisible by 400. For instance, the years 1600 and 2000 are leap years, but 1700, 1800, and 1900 are not. Write a program that requests a year as input and states whether it is a leap year. (Test the program on the years 2008, 2009, 1900, and 2000.)

6. For each of the responses shown in the parentheses, determine the output displayed in the text box when the button is clicked.
Private Sub btnDisplay_Click(...) Handles btnDisplay.Click
Dim yearENIAC As Integer
'Ask question and obtain answer
Dim message As String
message = "In what year was the ENIAC computer completed?"
yearENIAC = CInt(InputBox(message))
'Respond to answer
Select Case yearENIAC
Case 1945
txtOutput.Text = "Correct."
Case 1943 To 1947
txtOutput.Text = "Close, 1945."
Case Is < 1943
txtOutput.Text = "Sorry, 1945. Work on the ENIAC " & _
"began in June 1943."
Case Is > 1947
txtOutput.Text = "No, 1945. By then IBM had built " & _
"a stored-program computer."
End Select
End Sub
(1940, 1945, 1950)

7. Rewrite the code using a Select Case block.
If a = 1 Then
lstOutput.Items.Add("lambs")
End If
If ((a <= 3) And (a < 4)) Then
lstOutput.Items.Add("eat")
End If
If ((a = 5) Or (a > 7)) Then
lstOutput.Items.Add("ivy")
End If

Reference no: EM13752052

Questions Cloud

Update your website to include a simple web form : Update your website to include a simple web form as discussed in your design document. Use JavaScript to validate the form contents and display the results of that validation to the user in a popup window
Organizational structure and strategic leadership : Discuss the following questions in relation to organizational structure and strategic leadership
What is the amount of their total tax liability : Jake and Christina are married and file a joint return for 2014 with taxable income of $100,000 and tax preferences and adjustments of $20,000 for AMT purposes. Their regular tax liability is $16,713. What is the amount of their total tax liability?
General journal entry for employers payroll tax liability : Prepare the general journal entry for the employer's payroll liability. Prepare the general journal entry for the employer's payroll tax liability. Prepare the general journal entry to liquidate the liabilities accrued in parts (a) and (b) on March 3..
Rewrite the code using a select case block : Rewrite the code using a Select Case block and Determine the output displayed in the text box when the button is clicked
Basis for determining bad debt expense : Credit Sales, $3,500,000 Sales Returns & Allowances $35,000 Accounts Receivable $200,000 and Allowance for Doubtful Accounts with a debit of $3,500. Prepare the general journal entry to record the end of the year adjusting entry if ABC uses 0.5% of N..
Describe the steps in an implementation plan : Describe the steps in an implementation plan. Identify possible project issues
Correcting entries and end-of-the period adjusting entries : Explain what type of accounts need: correcting entries, end-of-the period adjusting entries, adjusted trial balance, classified balance sheet, and the closing entries. ie. cash, accumulated depreciation, retained earnings, salaries, etc.
Betty and charles were partners. : Albert, Betty and Charles were partners. The following circumstances applied:(a) CapitalAccording to the partnership agreement, Albert and Betty each contributed $20,000. Charles contributed no capital.(b) Advances

Reviews

Write a Review

Programming Languages Questions & Answers

  Design application that would output payment coupons

Design the application that would output 12 payment coupons for each of the 15 apartments in each of the 20 buildings. Each coupon should contain the building number.

  Write a program to define constant

Display each of these constants in decimal, in hexadecimal, and as a character usingcout.

  Write application to input numbers in one dimensional array

Use a one dimensional array to solve the following problem: Write an application that inputs five numbers, each between 10 and 100, inclusive.

  Create program which lists total points scored

Create program which lists total points scored for each of 30 classrooms. Include invalid input check if a proper room number is not entered.

  Write pseudocode that takes number entered by user

Write a piece of pseudocode that takes a number entered by the user and prints out every number from that number up to 100 and then prints END.

  Write temperature conversion program

You will write a temperature conversion program. GUI and event handling setup must be done in the constructor of the class that implements the GUI.

  Develop unix shell script to input number of hours

Develop a Unix shell script to input number of hours worked and pay rate and calculate the total pay, then the social security amount (assume 5%), then the net pay.

  Write program to read file having student'' test scores

Write a C++ program that reads a file named "grades.txt" consisting of students' test scores in the range 0-200 (all integer values). (The first number in the file specifies the number of grades it contains.

  Determines the aproximate number

Show how this can be done in a loop so the user can see resuts in a table. Let the output display and have headings for Day and Number of Bacteria Present on that day?

  Design program which models worms behavior

Design a program that models the worms behavior in the following scenario: A worm is moving toward an apple. Each time it moves, the worm cuts the distance between itself and the apple.

  Write down script to report cumulative size of all files

Write down script which will report cumulative size of all files in and below given directory. Your script will also report name and size (in bytes) of largest file with that directory tree.

  Determine proper lower bound and upper bound on ?nal value

Determine the proper lower bound and upper bound on the ?nal value of the shared variable tally output by this concurrent program.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd