Bahir Dar University, Institute of Technology, School of Computing and Electrical Engineering
Event Driven Programming Mid Term Examination (33%)
Time allowed:1:30 Name: ID: Instruction: Write your answer on separate answer sheet provided(33%) 1) What is an event in visual programming and give two examples of event.(4pts) 2) You are given the following user interface of visual C# application that is used to accept two numbers and computes sum and quotient of the two numbers. (Name of controls: text Box: textBox1, textBox2, textBox3, textBox4)
a) Write Visual C# code that will be attached on computebutton to compute sum and quotient, and display on textbox3 and textbox4 respectively(6pts) private void cmdCompute_Click(object sender, EventArgs e) { //write your answet that is intended to be typed here } b) Write Visual C# code that will be attached on Clear button to clear on contents of textBox1, textBox2 textBox3, textBox4 sum and quotient.(2pts) private void cmdClear_Click(object sender, EventArgs e) {
//write your answet that is intended to be typed he } 3) You are given the following user interface of the application, that is used to accept coefficients of quadratic equations and comput real roots of the quadratic equation. Write a C# code(intended to be attached on button Solve) that computes real roots of quadratic equations. Your program should check whether coeffitience a is non zero number. If it is zero your program should display error message leading coefficient must not be zero. If the quadratic equation has not real roots, textBox4 and textBox5 should be invisible. If the quadratic equation has only one root, textBox4 should be visible, but textBox5 should be invisible. You are not expected to write a code for the button clear and close (Name of Controls: TextBox for accepting coefficeints of quadrastic equations:textBox1, textBox2 and textBox3. TextBox for displaying real roots of quadrastic equations: textBox4 and textBox5)(8pts)
4) Your are given the following user interface of visual C# application, which accepts two numbers and compute the result based on the check box and radio buttons selected and display the result on list box. In order to perform the required task, write a C# code that will be attached on the button solve. Suppose user of your program enters 11 and 16 in textBox1 and textBox2 respectively. If the user selects Even Numbers check box and second number only radio button, your program should display even numbers such as 12,14 and 16 in list box. If the user selects odd number check box and both radio button, your program should display odd numbers 11,13,15 in list box. (13pts) (Name of controls: Radiobuttons: radioButton1, radioButton2 and radioButton3;TextBoxes: textBox1and textBox2; CheckBoxes: checkBox1 and checkBox2, listBox: listBox1)