{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "127cd496-5cf8-49c9-92c8-1f92b02d822a",
   "metadata": {},
   "source": [
    "```{index} homework; grade_calc I\n",
    "```\n",
    "\n",
    "(homework-grade-calculation)=\n",
    "\n",
    "# Homework: Grade Calculation\n",
    "\n",
    "Create a program file `grade_calc.cs` for this assignment.\n",
    "You are going to be\n",
    "putting together your first programming assignment where\n",
    "you will be taking the various concepts we have learned\n",
    "thus far from class and to put together your first\n",
    "meaningful program on your own.\n",
    "\n",
    "This program will incorporate the following elements:\n",
    "\n",
    "- Prompt a user for input.\n",
    "- Perform some rudimentary calculations.\n",
    "- Make some decisions.\n",
    "- Produce output.\n",
    "\n",
    "As we’ve mentioned earlier in class, our focus is going\n",
    "to be on learning how to write computer programs that start\n",
    "with a Main() function and perhaps use other functions as\n",
    "needed to *get a particular job done*. Eventually, we will\n",
    "be incorporating more and more advanced elements, such as\n",
    "classes and objects. For now, we would like you to organize\n",
    "your program according to the guidelines set forth here.\n",
    "\n"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "4d39084a",
   "metadata": {},
   "source": "## Program Summary\n\nOur first program is based on a common task that every\ncourse professor/instructor needs to do: make grades. In\nany given course, there is a *grading scale* and a set of\n*categories*.\n\nHere is sample output from two runs of the program.\nThe only data entered by the user are\nshow in **boldface** for illustration here.\n\nOne successful run with the data used above:\n\n> Enter weights for each part as an integer\n>\n> percentage of the final grade:\n>\n> Exams:\n>\n> **40**\n>\n> Labs:\n>\n> **15**\n>\n> Homework:\n>\n> **15**\n>\n> Project:\n>\n> **20**\n>\n> Participation:\n>\n> **10**\n>\n> Enter decimal numbers for the averages in each part:\n>\n> Exams:\n>\n> **50**\n>\n> Labs:\n>\n> **100**\n>\n> Homework:\n>\n> **100**\n>\n> Project:\n>\n> **100**\n>\n> Participation:\n>\n> **5**\n>\n> Your grade is 70.5%\n>\n> Your letter grade is C-.\n\nA run with bad weights:\n\n> Enter weights for each part as an integer\n>\n> percentage of the final grade:\n>\n> Exams:\n>\n> **30**\n>\n> Labs:\n>\n> **10**\n>\n> Homework:\n>\n> **10**\n>\n> Project:\n>\n> **10**\n>\n> Participation:\n>\n> **10**\n>\n> Your weights add to 70, not 100.\n>\n> This grading program is ending."
  },
  {
   "cell_type": "markdown",
   "id": "3ed1f786",
   "metadata": {},
   "source": "## Details\n\nMake your program file have the name `grade_calc.cs`.\n\nThis is based on the idea of Dr. Thiruvathukal’s own\nlegendary course syllabus.\nWe’re going to start\nby assuming that there is a fixed set of categories.\nAs an example we assume Dr. Thiruvathukal’s categories.\n\nIn the example below we work out for\nDr. Thiruvathukal’s weights in each category,\nthough your program should prompt\nthe user for these integer percentages:\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\nYour program will prompt the user for each the weights\nfor each of the categories. These weights will be entered\nas integers, which must add up to 100.\n\nIf the weights do not add up to 100, print a message and\nend the program. You can use an {{ if_else }} construction\nhere. An alternative is an `if` statement to test for a bad sum.\nIn the block of statements that go with the `if` statement,\nyou can put not only the message to the user, but also a\nstatement:\n\n    return;\n\nRecall that a function ends when a return statement is reached.\nYou may not have heard that this can also be used\nwith a `void` function. In a `void` function\nthere is no return value in the `return` statement.\n\nAssuming the weights add to 100, then we will use\nthese weights to compute your\ngrade as a `double`, which gives you the\nbest precision when it comes to floating-point arithmetic.\n\nWe’ll talk in class about why we want the weights to be\nintegers. Because floating-point mathematics is not 100%\nprecise, it is important that we have an accurate way\nto know that the weights *really add up* to 100. The only\nway to be assured of this is to use *integers*. We will\nactually use floating-point calculations to compute the\ngrade, because we have a certain tolerance for errors at\nthis stage. (This is a fairly advanced topic that is\ncovered extensively in courses like COMP 264/Systems\nProgramming and even more advanced courses like Numerical\nAnalysis, Comp 308.)\n\nWe are going to pretend\nthat we already know our score (as a percentage) for each\none of these categories, so it will be fairly simple to\ncompute the grade.\n\nFor each category, you will define a weight (int) and a\nscore (double). Then you will sum up the weight \\* score and\ndivide by 100.0 (to get a double-precision floating-point\nresult).\n\nThis is best illustrated by example.\n\nGeorge is a student in SIT 1551. He has the following\naverages for each category to date:\n\n- exams: 50%\n- labs: 100%\n- homework: 100%\n- project: 100%\n- participation: 5%\n\nThe following session with the `csharp` interpreter shows\nthe how you would declare all of the needed variables and\nthe calculation to be performed:\n\n``` none\ncsharp> int exam_weight = 40;\ncsharp> int lab_weight = 15;\ncsharp> int hw_weight = 15;\ncsharp> int project_weight = 20;\ncsharp> int participation_weight = 10;\n\ncsharp> double exam_grade = 50.0;\ncsharp> double lab_grade = 100;\ncsharp> double homework_grade = 100;\ncsharp> double project_grade = 100;\ncsharp> double participation_grade = 5;\n```\n\nThis is intended only to be as an example though. Your\nprogram must ask the user to enter each of these variables.\n\nOnce we have all of the weights and scores entered, we\ncan calculate the grade as follows. This is a long\nexpression: It is continued on multiple lines. Recall all\nthe `>` symbols are csharp prompts are not part of the\nexpression:\n\n``` none\ncsharp> double grade = (exam_weight * exam_grade +\n      > homework_weight* homework_grade +\n      > lab_weight * lab_grade + project_weight * project_grade +\n      > participation_weight * participation_grade) / 100.0;\n```\n\nThen you can display the grade as a percentage:\n\n``` none\ncsharp> Console.WriteLine(\"Your grade is {0}%\", grade);\nYour grade is 70.5%\n```\n\nNow for the fun part. We will use `if` statements to\nprint the letter grade. You will actually need to use\nmultiple `if` statements to test the conditions. A way\nof thinking of how you would write the logic for determining\nyour grade is similar to how you tend to think of the *best*\ngrade you can *hope for* in any given class. (We know that\nwe used to do this as students.)\n\nHere is the thought process:\n\n- If my grade is 93 (93.0) or higher, I’m getting an A.\n- If my grade is 90 or higher (but less than 93), I\n  am getting an A-.\n- If my grade is 87 or higher (but less than 90), I\n  am getting a B+.\n- And so on…\n- Finally, if I am less than 60, I am unlikely to pass.\n\nWe’ll come to see how *logic* plays a major role in\ncomputer science–sometimes even more of a role than\nother mathematical aspects. In this particular program,\nhowever, we see a bit of the best of both worlds. We’re\ndoing *arithmetic* calculations to *compute* the grade.\nBut we are using *logic* to determine the grade in the\ncold reality that we all know and love: the bottom-line\ngrade.\n\nThis assignment can be started after the data chapter,\nbecause you can do most all of it with tools\nlearned so far. Add the parts with `if` statements\nwhen you have been introduced to `if` statements.\n(Initially be sure to use data that makes the\nweights actually add up to 100.)\n\nYou should be able to write the program more concisely\nand readably if you use functions developed\nin class for the prompting user input."
  },
  {
   "cell_type": "markdown",
   "id": "346dd46b",
   "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- Enter weights, with prompts **\\[3\\]**\n\n- End if the weights do not add to 100: **\\[5\\]**\n\n- Enter grades, with prompts: **\\[3\\]**\n\n- Calculate the numerical average and display with a label: **\\[5\\]**\n\n- Calculate the letter grade and display witha label: **\\[5\\]**\n\n- Use formatting standards for indentation: **\\[4\\]**\n\n  - Sequential statements at the same level of indentation\n  - Blocks of statements inside of braces indented\n  - Closing brace for a statement block always lining up with the\n    heading before the start of the block."
  },
  {
   "cell_type": "markdown",
   "id": "a725a840",
   "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 later just change its name (but not its format) in the file system."
  }
 ],
 "metadata": {},
 "nbformat": 4,
 "nbformat_minor": 5
}