{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "c4143dcd-43b2-48bf-94c1-d30ea67a7e9e",
   "metadata": {},
   "source": [
    "```{index} homework; grade calculation 2\n",
    "```\n",
    "\n",
    "(homework-grade-calculation2)=\n",
    "\n",
    "# Homework: Grade Calculation from Individual Scores\n",
    "\n",
    "In the previous assignment, we calculated grades based on a *memorized*\n",
    "overall grade within each of the categories below, as in this example:\n",
    "\n",
    "- exams - 40% (integer weight is 40)\n",
    "- labs - 15% (weight 15)\n",
    "- homework - 15% (weight 15)\n",
    "- project - 20% (weight 20)\n",
    "- participation - 10% (weight 10)\n",
    "\n",
    "In this assignment, we are going to change the specification slightly\n",
    "to make the program a bit smarter. Instead of someone having to remember\n",
    "what their average grade was for each category, we will prompt the user for\n",
    "the number of items within each category (e.g. number of exams, number\n",
    "of labs, etc.), have the user enter individual grades, and have the program\n",
    "calculate the average for the category.\n",
    "\n",
    "As usual, we will begin by specifying *requirements*.\n",
    "User responses are shown **bold faced**.\n",
    "\n"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "ca966684",
   "metadata": {},
   "source": "## Functional Requirements\n\n1.  Instead of bombing out if the weights don’t add up to 100, use {ref}`do-while`\n    to prompt the user again\n    for all of the weights until they do add up to 100. A `do { ... } while`\n    loop is the right choice here, because you can test all of the weights\n    at the end of the loop, after each time they have been entered\n    in the loop.\n\n2.  Write a function, `FindAverage`,\n    to do the following. The example refers to the category exam,\n    but you will want your code to work for each\n    category, and hence the category\n    *name* will need to be a parameter to `FindAverage`.)\n\n    Prompt the user for the number of items in the category:\n\n    > Please enter the number grades in category exam: **4**\n\n    Instead of prompting the user for an overall average\n    exam grade, use a loop to\n    read one grade at a time. The grades will be added together (on the fly)\n    to give the grade for that category. For example, after you have asked\n    for the number of exams, you’d prompt the user to enter each exam\n    grade and have the program compute the sum. As soon as a category\n    sum is calculated, also print out the average as shown in the sample below:\n\n    > Please enter the grade for exam 1:\n    >\n    > **100**\n    >\n    > Please enter the grade for exam 2:\n    >\n    > **90**\n    >\n    > Please enter the grade for exam 3:\n    >\n    > **80**\n    >\n    > Please enter the grade for exam 4:\n    >\n    > **92**\n    >\n    > Calculated average exam grade = 90.5\n\n    Of course you must return the grade to the caller for use in the\n    overall weighted average grade.\n\n    A category may have only a single grade, in which case the\n    user will just enter the number of grades as 1.\n\n3.  Once you have read in the data for each of the items within a category,\n    you’ll basically be able to *reuse* the code that you developed in the\n    previous assignment to compute the weighted average and print the\n    final letter grade.\n\n4.  Print the final numerical average, *this time rounded to one decimal place*.\n    If the final average was actually 93.125, you would print 93.1.\n    If the final average was actually 93, you would print 93.0.\n    If the final average was actually 93.175, you would print 93.2."
  },
  {
   "cell_type": "markdown",
   "id": "6759a1d8",
   "metadata": {},
   "source": "## Style Requirements\n\n1.  For this assignment, you are expected to start using functions for all\n    aspects of the assignment. For example, it can become tedious in a hurry\n    to write code to prompt for each of exams, labs, homework, etc. when\n    a single function (with parameter named *category*) could be used to\n    avoid repeating yourself. In particular you should\n    write your function to take advantage of our `UI`\n    class, from {ref}`the-ui-class`.\n\n2.  Also beginning with this assignment, it is expected that your work\n    will be presented neatly. That is, we expect the following:\n\n    - proper indentation that makes your program more readable by other\n      humans. Use all spaces, not tabs to indent. You never know what\n      default tabs your grader will have set up.\n    - proper naming of classes and functions. In C#, the convention is to\n      begin a name with a capital letter. You can have multiple words in a\n      name, but these should be capitalized using a method known as\n      CamelCase [1]. We also recommend this same naming convention\n      for variables but with a lowercase first letter.\n      For variables, we are also\n      ok with the use of underscores. For example, in homework 1 we used\n      names like `exam_grade`. If you use CamelCase, you can name this\n      variable `examGrade`.\n    - If you have any questions about the neatness or appearance of your\n      code, please talk to the instructor or teaching assistant.\n    - This guide from CIS 193 at [2]\n      provides a nice set of conventions\n      to follow. We include this here so you know that other faculty at\n      other universities also consider neatness/appearance to be important."
  },
  {
   "cell_type": "markdown",
   "id": "671c9ae9",
   "metadata": {},
   "source": "## Grading Rubric\n\nAs a general rule, we expect programs to be complete,\ncompile correctly, run, and be\nthoroughly tested. We are able to grade an incomplete program\nbut will only give at most 10/25\nfor effort. Instead of submitting something incomplete,\nyou are encouraged to complete your program and\nsubmit it per the late policy. Start early and get help!\n\n25 point assignment broken down as follows:\n\n- Loop until weights add to 100: 5\n- Average any number of grades in a category: 5\n- One function that is reused and works for the average in each category: 5\n- Print final numerical grade rounded to one decimal place: 2\n- Previous program features still work: 3\n- Style: 5"
  },
  {
   "cell_type": "markdown",
   "id": "9314a505",
   "metadata": {},
   "source": "## Logs and Partners\n\nYou may work with a partner, following good pair-programming practice,\nsharing responsibility for all parts.\n\nOnly one of a pair needs to submit the actual programming assignment.\nHowever *both* students, *independently*, should write and\ninclude a log in their\nHomework submission. Students working alone should also submit a log,\nwith fewer parts.\n\nEach individual’s log should indicate each of the following clearly:\n\n- Your name and who your partner is (if you have one)\n- Your approximate total number of hours working on the homework\n- Some comment about how it went - what was hard …\n- An assessment of your contribution (if you have a partner)\n- An assessment of your partner’s contribution (if you have a partner).\n\nJust omit the parts about a partner if you do not have one.\n\nName the log file with the exact file name:\n“log.txt” and make it a plain text file.\nYou can create it in a program editor or in a fancy document editor.\nIf you use a fancy document editor, be sure to a “Save As…” dialog,\nand select the file format “plain text”,\nusually indicated by the “.txt” suffix.\nIt does not work to save a file in the default word processor format, and\nthen just change its name (but not its format) in the file system.\n\n[1] <http://en.wikipedia.org/wiki/CamelCase>\n\n[2] <http://www.cis.upenn.edu/~cis193/csstyle.html>"
  }
 ],
 "metadata": {},
 "nbformat": 4,
 "nbformat_minor": 5
}