advertisement

152111011 INTRODUCTION TO PROGRAMMING LAB LAB WORK 7 Objectives: Functions with input parameters Start Programs Microsoft Visual Studio 2015 File New Project Select Visual C# Windows Windows Forms Applications and write project name Lab07 at bottom. 1. Write a C# program that accepts three floating-point numbers as input parameters from textBoxes, finds the average of these numbers, and displays the result in a label. In addition write a function that name of showaverage() to calculate average of three numbers. A sample run may be as follows; 2. Write a C# program that accepts an integer value as the time in seconds, and displays the time in hours, minutes and seconds. A sample run may be as follows: 1 3. Write a program that enters the a, b, and c coefficients of a second-degree polynomial ax2 + bx + c, then compute and display its roots using the following below: Use Math.Sqrt for square root of numbers The two roots are defined as b b 2 4ac root1 = 2a b b 2 4ac root2 = when discriminant (b2 – 4ac) > 0 2a a) If ∆ = 𝑏 2 − 4𝑎𝑐 < 0 : Give a message like No roots! b) If ∆ = 𝑏 2 − 4𝑎 = 0 : Give a message like Two coincident real roots! c) If ∆ = 𝑏 2 − 4𝑎𝑐 > 0 : Give a message like Two distict real roots! A sample run may be as follows: 4. Write a C# program that accepts the score of a student as its parameter, then determines and returns the equivalent letter grade according to the following criteria: Score Letter grade ≥ 90 A 80 ≤ score ≤ 89 B 70 ≤ score ≤ 79 C 50 ≤ score ≤ 69 D <50 F Include the function in a working program. The student’s score have to read from textBox and button1_Click()calls the function letter_grade() to find the equivalent letter grade. a) Grade is less than 0 : Give an error message like: Grade must be greater than 0! b) Grade is greater than 100: Give an error message like: Grade must be less than 100! 2 A sample run may be as follows: 3