C Sharp programming This statement X is equivalent to 2 Wr

C Sharp programming

This statement ++ X; is equivalent to: ___________________________

2. Write a C# expression for this formula: 1+X^AB/C+D_________________________________

3. If variable x, y and z are integer and are initialized to x=10 and y=3, what is the value of z: z=x / y; z = x % y;

4. The rules to determine bonus based on employee job code are: JobCode = 1 300 JobCode = 2 500 JobCode = 3 700 JobCode = 4 1000 Use a decision structure to implement these rules.

5. State University calculates students tuition based on the following rules: – State residents: ( • Total units taken <=12, tuition = 1200 • Total units taken > 12, tuition = 1200 + 200 per additional unit. – Non residents: • Total units taken <= 9, tuition = 3000 • Total units taken > 9, tuition = 3000 + 500 per additional unit. Assuming a Boolean variable named Resident and two double variables named totalUnits and Tuition already declared and initialized, write a decision structure to compute the tuition.

6. A Group Panel control contains 3 radio buttons: Radio1, Radio2, and Radio3. Complete the following click event procedure to determine which radio button is checked, and uses a MessageBox to show the selected option with a message such as “ Radio 1 is checked”. private void button2_Click(object sender, EventArgs e) { }

7. A program computing the quotient and remainder of a division is given below. Identify two possible errors when you run this program. private void button1_Click(object sender, EventArgs e) { int dividend, divisor, quotient, remainder; dividend = int.Parse(textBox1.Text); divisor = int.Parse(textBox2.Text); quotient = dividend / divisor; remainder = dividend % divisor; textBox3.Text = quotient.ToString(); textBox4.Text = remainder.ToString(); }

8. An integer is stored in a variable MyInt. Write the if statement to test if MyInt is divisible by 5 and use MessgeBox to show “Divisible by 5” or “Not divisible by 5”.

Solution

1. ++X is eqivalent to X=X+1 as it is a pre-increment operator.

2.1+X^AB/C+D is written in C# as following:

1+Math.Pow(X, A)*B/C+D

3. If x=10 and y=3, the value of z after z=x / y will be 10/3 i.e. 3 (as both are int)

After z = x % y it will be 10%3 i.e. 1 as 1 will be the remainder.

8. Since MyInt is an int we can check it like this:

if(MyInt%5 == 0){

}else{

}

C Sharp programming This statement ++ X; is equivalent to: ___________________________ 2. Write a C# expression for this formula: 1+X^AB/C+D____________________

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site