Windows Programming Assignment I: GPA Calculator

You are about to develop a software product that calculates semester GPA for college students. A screenshot of a sample software is given below.

The detailed requirements of the software are:
  1. The GPA Calculator accepts up to four classes. A newer version of the software will be released soon to handle any number of classes.
  2. The grades must be letter grades: A(4.0), B(3.0), C(2.0), D(1.0), and F(0.0). The numbers in the parentheses are the corresponding credit points earned. An error message should be displayed if the user enters an invalid grade.
  3. The class names must be in the format: a three-letter course acronym followed by a four digit course number with no spaces in between. The Calculator should be intelligent enough to figure out the number of credit hours of a course from its acronyn and number.
  4. A credit hour weighted GPA should be calculated and displayed with two decimal places, after the user pushes a calculate button.
  5. Extra points will be awarded to those aesthetic design work.


0). Before submitting your final software product, ask a classmate to test your software. You need to provide a short description of the test and tester's name.
1). A screenshot of your final software product with test data on it (See the sample screenshot).
2). C# code
3). Put both code and screenshot into a pdf file and submit to the Bb.

Partially completed code is provided as reference. Note that the names of the graphical elements such as textbox and labels used in the code might be different from yours. Also, ... means you need to complete the missing code. Feel free to add more code if needed.

        private void button1_Click(object sender, EventArgs e)
            //Declare variables for numeric grades
            double grade1;

            //Declare variables for credit hours
            double hours1;

            double gpa = 0;

            //Convert letter grades to numeric grades
            grade1 = getNumericScore(textBox2.Text.ToString());

            //Credit hours from the class names.
            //Note the starting index of string characters is from 0
            hours1 = Convert.ToDouble(textBox1.Text.Substring(4, 1));

            //Weighted average GPA
            gpa = ...;

            //Round to two decimal places
            gpa = Math.Round(gpa * 100) / 100;
            //Display the GPA on a text label on the form with two decimal places
            label3.Text = gpa.ToString("0.00");

        //Given a letter, convert corresponding numeric grade
        private double getNumericScore(String letterGrade)
            double score = 0.0;

            switch (letterGrade)
                case "A":
                case "a":
                    score = 4.0;
                case "F":
                case "f":
                    score = 0.0;
                    MessageBox.Show("The letter grade entered is invalid");

            return score;