Write a method integerPower ( base, exponent ) that returns the value of ? base exponent
For example, integerPower (3,4) calculates 34( or 3∗3 in 3∗3).34( or 3∗3 in 3∗3). Assume that exponent is a positive, nonzero integer and that base is an integer. Method integerPower should use a for or while statement to control the calculation. Do not use any math library methods. Incorporate this method into an application that reads integer values for base and exponent and performs the calculation with the integerPower method.
Show the value of x after each of the following statements is performed:
a) x = fabs (7.5)
b) x = floor (7.5)
c) x = fabs (0.0)
d) x = ceil (0.0)
e) x = fabs (?6.4)
f) x = ceil (?6.4)
g) x = floor (?6.4)
h) x = ceil( ? fabs (?8 + floor (?5.5)))
A parking garage charges a $2.00 minimum fee to park for up to three hours. The garage charges an additional $0.50 per hour for each hour or part thereof in excess of three hours. The maximum charge for any given 24-hour period is $10.00. Assume that no car parks for longer than 24 hours at a time. Write an application that calculates and displays the parking charges for each customer who parked in the garage yesterday. You should enter the hours parked for each customer. The program should display the charge for the current customer and should calculate and display the running total of yesterday’s receipts. It should use the method calculateCharges to determine the charge for each customer.
Using implicit sizing, assign the integers 2, 3, 5, 7, 11, and 13 to an array named intPrimeNumbers.
2. Answer the following questions about the following initialized array: Dim strSeafood(8) as String
a. Assign Oysters to the first array location. What is the index number?
b. Assign Lobster to the fourth location in the array. What would the assignment statement look like?
c. What value does strSeafood.Length have?
d. How many types of seafood can this array hold?
e. What would happen if you assigned strSeafood(9) = “Red Snapper”
4. Write a For Each loop that displays every element of an array named strSongNames in a ListBox named lstDisplay. The loop variable is named strPlay.
Write a VB program to calculate the wages based on different rates (Normal hours and Overtime rates).
Write a FUNCTION to calculate the wages based on the following condition:
-Normal Hours: RM 10 per hours
-Overtime: RM 15 per hours
NOTE: The function should pass in a value of hours as Double, and a value of type as String. The function should return the calculated amount of wages and return as a Double.
*set the Enabled properties of the Total Wages Text Box to False
Example
NormalHours: XXX
OverTime: XXX
Button
Wages: XXX
2. Answer the following questions about the following initialized array: Dim strSeafood(8) as String
a. Assign Oysters to the first array location. What is the index number?
b. Assign Lobster to the fourth location in the array. What would the assignment statement look like?
c. What value does strSeafood.Length have?
d. How many types of seafood can this array hold?
e. What would happen if you assigned strSeafood(9) = “Red Snapper”?
4. Write a For Each loop that displays every element of an array named strSongNames in a ListBox named lstDisplay. The loop variable is named strPlay.
1. Using implicit sizing, assign the integers 2, 3, 5, 7, 11, and 13 to an array named intPrimeNumbers.
3. Rewrite the code below to read each line of a text file into an array named strFordModel.
Consider the same Do While loop in question 4 above to answer the following questions:
(a) How many times the loop condition is tested?
(b) How many times the body of the Do While loop is executed?
(c) What is the final value of intSum and intCount variables after the loop ends?
3. Study the following code. what messages will be displayed in the message box?
Dim intCounter As Integer
Dim dblSum As Double, dblNumber As Double
dblSum = 0
intCounter = 1
Do While intCounter < 6
dblSum = dblSum + Convert.ToDouble(intCounter)
If intCounter Mod 3 = 0 Then
dblNumber = 5.0
End If
dblSum = dblSum + dblNumber
intCounter = intCounter + 2
Loop
MessageBox.Show("The Sum is: " & dblSum.ToString(),"IS122")
4. Rewrite the following section of code using a For Next loop instead of a Do While loop.
Dim intSum As Integer
int intCount As Integer
intCount = -5
Do While intCount <= 15
intSum = intSum + intCount
intCount = intCount + 1
Loop
1. Consider the following code segments using the Boolean variables a, b, c and d.
If Not c Or d Then
If a And c Then
lblOut.Text = “1”
ElseIf b Then
lblOut.Text = “2”
Else
lblOut.Text = “3”
End If
ElseIf Not c = d Then
lblOut.Text = “4”
ElseIf c Then
lblOut.Text = “5”
Else lblOut.Text = “6”
End If
a. Give the values for a, b, c and d that will cause the above code segment to display 1 in lblOut.
b. Give the values for a, b, c and d that will cause the above code segment to display 4 in lblOut.
2. Write VB.NET code that will use a loop to calculate the sum of all integer numbers between 5 and 100 that are divisible by both 5 and 6.
You may choose to use any looping structure.
Use the following variable declarations.
Dim intCounter As Integer ‘loop counter variable
Dim intSum As Integer ‘to accumulate the summation