Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

This Module is mainly to practice If ... Then ... ElseIf ... with creating a project in VB Open Visual Basic and create a new

This Module is mainly to practice If ... Then ... ElseIf ... with creating a project in VB

  1. Open Visual Basic and create a new Project. Select Windows Form New Project window. You will save this project in your CS 3 folder and name it as:yourlastname-firstname-Grader.
  2. In this project user inputs three test scores, a button calculates the average and displays the average and grade. Another button clears the entries.
  3. Create a form withsevenlabels,threetextboxes andtwobuttons, similar to below form layout with each control.
  4. Here are the properties of the form and each control:
  5. Form: change thetitleof the form to: - Grader
  6. Label1, Text: Test1; Name: leave as is, you dont use labels in the program
  7. Label2, Text: Test2; Name: leave as is
  8. Label3, Text: Test3; Name: leave as is
  9. Label4, Text: Average; Name: leave as is
  10. Label5, Text: Grade; Name: leave as is
  11. Label6, Text: blank; Name: lblAverage ; BorderStyle: Fixed 3D; AutoSize: False
  12. Label7, Text: blank; Name: lblGrade ; BorderStyle: Fixed 3D; AutoSize: False
  13. Textbox1, Test: blank; Name: txtTest1
  14. Textbox2, Test: blank; Name: txtTest2
  15. Textbox3, Test: blank; Name: txtTest3
  16. Button1, Text: Calculate Average; Name: btnCalcAvg
  17. Button2, Text: Clear; Name: btnClear
  18. Write a Visual Basic program that: 1) accepts three scores, 2) computes the average and assigns the grade.
  19. You declare four variables as Integer data type. They are: Test1, Test2, Test3, and Average.
  20. You create an IFELSEIF structure to assign grades using this logic. Note:No need to create a loop:
  21. To assign Letter Grade use this criteria:Average 60,>70,>=100,>.
  22. To do this you write the code in Calculate Average button procedure. First declare the variables that will get test scores (intTest1, intTest2, intTest3) from textboxes and another one (intAverage) for calculating the tests average. Then assign textbox entries into the first three variables. Then calculate the Average and finally based on the Average assign a Letter Grade.
  23. Clear button clears the entries in Test1, Test2, Test3 textboxes and in Average and Grade labels. Then program is ready to take another set of test scores.Ready to enter another set of numbers.
  24. After creating the following form layout in VB (see assignment 8 on how to create a new project). Make sure to name the controls according to above steps 11 - 17.
  25. Double-click on Calculate Average, you will placed in Code window to write code:
  26. Declare 4 variables: intTest1, intTest2, intTest3, intAverage as Integer.
  27. Assign textbox entries for three scores into intTest1, intTest2, intTest3 variables, Example: intTest1 = txtTest1.Text
  28. Calculate Average, develop an expression to sum three tests values and divide by 3. Store Average into intAverage variable.
  29. Then develop nested IF THEN ELSEIF ELSEIF selection structure to evaluate Average and assign a Letter Grade.
  30. You display the average and assigned grade in Average and Grade label controls
  31. We have reviewed similar nested selection structure in Selection slides.
  32. You may want to start with a similar code below and make sure to make the necessary changes. Before starting to build IF statement, dont forget to declare the variables and assign Test1, Test2, Test3 to their corresponding variables. Also calculating the Average of three tests:

IfAverage

lblAvg.Text = Average

lblGrade.Text =\"F\"

ElseIfAverage

lblAvg.Text = Average

lblGrade.Text =\"D\"

ElseIfAverage

lblAvg.Text = Average

lblGrade.Text =\"C\"

ElseIfAverage

lblAvg.Text = Average

lblGrade.Text =\"B\"

ElseIfAverage

lblAvg.Text = Average

lblGrade.Text =\"A\"

EndIf

  1. To program Clear button, double-click on Clear button on the form.
  2. Type the code to clear the textboxes and label controls entries:
  3. You can use the following sample code:

txtTest1.Text =\"\"

lblAvg.Text =\"\"

lblGrade.Text =\"\"

Form layout with controls

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Mobile Communications

Authors: Jochen Schiller

2nd edition

978-0321123817, 321123816, 978-8131724262

More Books

Students also viewed these Programming questions