In the previous assignment, we calculated grades based on a m e m o r i z e d overall grade within each of the categories below, as in this example:

  • exams - 40% (integer weight is 40)
  • labs - 15% (weight 15)
  • homework - 15% (weight 15)
  • project - 20% (weight 20)
  • participation - 10% (weight 10)

In this assignment, we are going to change the specification slightly to make the program a bit smarter. Instead of someone having to remember what their average grade was for each category, we will prompt the user for the number of items within each category (e.g. number of exams, number of labs, etc.), have the user enter individual grades, and have the program calculate the average for the category.

As usual, we will begin by specifying r e q u i r e m e n t s . User responses are shown bold faced.

Functional Requirements

1. Instead of bombing out if the weights dont add up to 100, use D o - W h i l e L o o p s (do-while.html#dowhile) to prompt the user again for all of the weights until they do add up to 100. A do{...} while loop is the right choice here, because you can test all of the weights at the end of the loop, after each time they have been entered in the loop.

2. Write a function, FindAverage , to do the following. The example refers to the category exam, but you will want your code to work for each category, and hence the category n a m e will need to be a parameter to FindAverage .)

Prompt the user for the number of items in the category:

Please enter the number grades in category exam: 4

Instead of prompting the user for an overall average exam grade, use a loop to read one grade at a time. The grades will be added together (on the fly) to give the grade for that category. For example, after you have asked for the number of exams, youd prompt the user to enter each exam grade and have the program compute the sum. As soon as a category sum is calculated, also print out the average as shown in the sample below:

Please enter the grade for exam 1: 100
Please enter the grade for exam 2: 90
Please enter the grade for exam 3: 80
Please enter the grade for exam 4: 92
Calculated average exam grade = 90.5

Of course you must return the grade to the caller for use in the overall weighted average grade.

A category may have only a single grade, in which case the user will just enter the number of grades as 1.

3. Once you have read in the data for each of the items within a category, youll basically be able to r e u s e the code that you developed in the previous assignment to compute the weighted average and print the final letter grade.

4. Print the final numerical average, t h i s t i m e r o u n d e d t o o n e d e c i m a l p l a c e . If the final average was actually 93.125, you would print 93.1. If the final average was actually 93, you would print 93.0. If the final average was actually 93.175, you would print 93.2.

Style Requirements

1. For this assignment, you are expected to start using functions for all aspects of the assignment. For example, it can become tedious in a hurry to write code to prompt for each of exams, labs, homework, etc. when a single function (with parameter named c a t e g o r y ) could be used to avoid repeating yourself. In particular you should write your function to take advantage of our UI class, from U s e r I n p u t : U I (userinput.html#ui)

2. Also beginning with this assignment, it is expected that your work will be presented neatly. That is, we expect the following:

  • proper indentation that makes your program more readable by other humans. Use all spaces, not tabs to indent. You never know what default tabs your grader will have set up.
  • proper naming of classes and functions. In C#, the convention is to begin a name with a capital letter. You can have multiple words in a name, but these should be capitalized using a method known as CamelCase [CamelCase]. We also recommend this same naming convention for variables but with a lowercase first letter. For variables, we are also ok with the use of underscores. For example, in homework 1 we used names like exam_grade. If you use CamelCase, you can name this variable examGrade.
  • If you have any questions about the neatness or appearance of your code, please talk to the instructor or teaching assistant.
  • This guide from CIS 193 at [UPennCSharp] provides a nice set of conventions to follow. We include this here so you know that other faculty at other universities also consider neatness/appearance to be important.
Academic Honesty!
It is not our intention to break the school's academic policy. Projects posted are only used as a reference and should not be submitted as is. We are not held liable for any misuse of the solutions. Please see the frequently asked questions page for further questions and inquiries.
Kindly fill out the form. Please provide a valid email address and we'll get back to you in less than 24 hours. We will be sending an invoice through PayPal upon confirmation. We are a non profit organization however we need an amount to keep this organization running, and to be able to complete our research and development.