Write an if-else statement that outputs the discount
The communication company offers a discount to customer who is taking at least 12-
month plan. The discount arrangement is as below: Business customer:
12/18 months 15% discount
24 months 25% discount
Non-Business customer
12/18 months 10% discount
24 months 15% discount
The variables customerType is of type char, period is of type int and discount is of
What does the following fragment display? (
) class MyClass
{
public static void main(String[] args) {
boolean b = true; int i = 2;
do
{
i++;
b = !b; } while (b);
System.out.println(i); }
}
Consider the following program written in Java and answer the question:
1. import java.util.*;
2. class Arraylist
3. {
4. public static void main(String args[])
5. {
6. ArrayList obj = new ArrayList();
7. obj.add("B");
8. obj.add("C");
9. obj.add("C");
10. obj.add("D");
11. obj.remove(2);
12. System.out.println(obj.get(1));
13. }
14. }
What would be the output of the statement when the program is executed?
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.
PYTHON CREATING CLASS AND ATTRIBUTE :
1. Create a Class and initialize attribute of the following:
Class name: Student
Attribute: First Name
Last Name
Sex
Age
2. From the created class, create 5 objects, and display it using pretty table.
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
There are different kinds of numbers, but among them all, the most commonly used numbers in our daily lives are those positive ones. So, I only want you to count all the positive numbers from the 4 outputted values and print out the result.
Go and search for the positive ones among these four!
Input
A line containing four numbers (may contain decimal places) separated by a space.
2·-4·3.6·1
Output
A line containing an integer.
3