Menu

(Solved) : Exercise Ll Design Form Lets User Enter Number Grade Displays Letter Grade User Clicks Cal Q44105027 . . .

  1. In this exercise, you’ll design a form that lets the user entera number grade and then displays the letter grade when the userclicks the Calculate button.

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

Defaultname                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:

Defaultname                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 thecontrols and the size of the form so they look as shown above.
  2. Rename the form to frmCalculateGrade. When you’re asked if youwant to rename any references to the form, click the Yesbutton.
  3. Open the CalculateLetterGrade project you created in your firsthomework.
  4. Display the form in the Form Designer, and double-click theCalculate button to generate a Click event handler for it. Then,add this statement to the event handler to get the number grade theuser enters:
  5. decimalnumberGrade = Convert.ToDecimal(txtNumberGrade.Text);

  6. Add this statement to the event handler to declare andinitialize the variable that will hold the letter grade:
  7. stringletterGrade = “”;

    Then, add this if-else statement toset 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 LetterGrade text box:
  9. txtLetterGrade.Text = letterGrade;

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

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

  14. Run the application, enter a number between 0 and 100, and thenclick the Calculate button. A letter grade should be displayed andthe focus should return to the Number Grade text box. Next, enter adifferent number and press the enter key to display the lettergrade for that number. When you’re done, press the Esc key to endthe application.

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

Expert Answer


Answer to In this exercise, you’ll design a form that lets the user enter a number grade and then displays the letter grade whe…

OR