Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In this exercise, youll design a form that lets the user enter a number grade and then displays the letter grade when the user clicks

  1. In this exercise, youll design a form that lets the user enter a number grade and then displays the letter grade when the user clicks the Calculate button.

  2. Start a new project named LastnameFirstNameCalculateLetterGrade. Be sure to store the solution in its own directory.
  3. Add the labels, text boxes, and buttons to the form as shown above. Then, set the properties of these controls as follows:

Default name Property Setting

label1 Text &Number grade: TextAlign MiddleLeft TabIndex 0

label2 Text Letter grade: TextAlign MiddleLeft

textBox1 Name txtNumberGrade TabIndex 1

textBox2 Name txtLetterGrade ReadOnly True TabStop False

button1 Name btnCalculate Text &Calculate TabIndex 2

button2 Name btnExit Text E&xit TabIndex 3

  1. Now, set the properties of the form as follows:

Default name Property Setting

Form1 Text Calculate Letter Grade AcceptButton btnCalculate CancelButton btnExit StartPosition CenterScreen

  1. Use the Form Designer to adjust the size and position of the controls and the size of the form so they look as shown above.
  2. Rename the form to frmCalculateGrade. When youre asked if you want to rename any references to the form, click the Yes button.
  3. Open the CalculateLetterGrade project you created in your first homework.
  4. Display the form in the Form Designer, and double-click the Calculate button to generate a Click event handler for it. Then, add this statement to the event handler to get the number grade the user enters:
  5. decimal numberGrade = Convert.ToDecimal(txtNumberGrade.Text);

  6. Add this statement to the event handler to declare and initialize the variable that will hold the letter grade:
  7. string letterGrade = "";

    Then, add this if-else statement to set the letter grade:

    if (numberGrade >= 88)

    {

    letterGrade = "A";

    }

    else if (numberGrade >= 80 && numberGrade <= 87)

    {

    letterGrade = "B";

    }

    else if (numberGrade >= 68 && numberGrade <= 79)

    {

    letterGrade = "C";

    }

    else if (numberGrade >= 60 && numberGrade <= 67)

    {

    letterGrade = "D";

    }

    else

    {

    letterGrade = "F";

    }

  8. Add this statement to display the letter grade in the Letter Grade text box:
  9. txtLetterGrade.Text = letterGrade;

  10. Finally, add this statement to move the focus back to the Number Grade text box:
  11. txtNumberGrade.Focus();

  12. Return to the Form Designer, and then double-click the Exit button to generate a Click event handler for it. Then, add this statement to the event handler to close the form:
  13. this.Close();

  14. Run the application, enter a number between 0 and 100, and then click the Calculate button. A letter grade should be displayed and the focus should return to the Number Grade text box. Next, enter a different number and press the enter key to display the letter grade for that number. When youre done, press the Esc key to end the application.

PLEASE SHOW ALL THE WORK ON C# MY CODE IS NOT WORKING

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_2

Step: 3

blur-text-image_3

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

More Books

Students also viewed these Databases questions

Question

3. I no longer feel able to cope with things.

Answered: 1 week ago

Question

What is the best way to provide encapsulation in C + + ?

Answered: 1 week ago