Comp 101 The Grade Calculator

The Grade Calculator

The goal of this problem set is to create program that prompts the user for their problem set, participation, and quiz grades in COMP101, and then the final grade the user hopes to have. Using this information, we will print out the exam grade needed by the user to achieve this grade.

Part 1.0 (a): Getting started.

  1. Right click on the "src" folder
  2. Select "New Folder"
  3. Name the new folder: ps01-grade-calculator
    1. Note: capitalization and punctuation are important!
  4. Right click on the ps01-grade-calculator
  5. Select "New File"
  6. Name the new file: 01-grades-app.ts
    1. Note: capitalization and punctuation are important!

Part 1.0 (b): Honor Code Header

All problem sets begin with an Honor Code pledge. Notice this header is contained within block comment tags discussed in Lecture 1. You can copy paste the pledge below and fill in your name and ONYEN.

/**
 * Author:
 *
 * ONYEN:
 *
 * UNC Honor Pledge: I certify that no unauthorized assistance has been received
 * or given in the completion of this work. I certify that I understand and
 * could now rewrite on my own, without assistance from course staff, 
 * the problem set code I am submitting.
 */

Part 1.0 (c): Import statements.

The next step after ensuring the Honor Code header is importing the functions we'll use from the introcs library (i.e. printimage, and so on).

import { print, promptNumber } from "introcs";

This imports the print and promptNumber functions so that we’ll be able to ask users for number input and display some values at the end of this part of the problem set.

Part 1.0 (d) The main Function

Your program's logic will begin a function named `main`. All of your code from this point on will go inside its brackets. Here is the incantation to setup your main function:

export let main = async () => {
   // TODO: Your code goes inside of this block.
};
main();

Part 1.1: Grade weight variables.

The first thing we need to do is store the weights of the various COMP101 grades in variables.

Here are the weights used in calculating grades (from the syllabus):

         Problem Sets: 35%

         Cumulative Final: 20%

         Participation (via PollEverywhere): 5%

         6 Quizzes: 40%

What you need to do: Declare four number variables named problemSetWeight, examWeight, participationWeight, and quizWeight. Then, assign to these variables the values that correspond to the percent of your final grade that each category makes up (so that problemSetWeight will contain the value 0.35 and so on).

Part 1.2: Getting the grades.

Now that we have stored the weights of COMP 101 grade categories, we need to ask the user for their problem set, participation, and quiz grades. We don’t need to ask for an exam grade, because the purpose of this program is to calculate the exam grade needed to achieve a goal final grade. Additionally, we will just ask the user for their average quiz grade (it would be painful to ask the user for 6 individual grades).

What you need to do: Declare three number variables named problemSetGrade, participationGrade, and averageQuizGrade. Then, assign the corresponding number values (provided by the user) to these variables. Note that these values should be a grade from 0 to 100 (not 0.0-1.0). For example, you should assign problemSetGrade the value of:

await promptNumber("What is your problem set grade, from 0-100?");

Similarly, you should prompt the user for their participation and quiz grades and store these values in participationGrade and averageQuizGrade.

Part 1.3: Goal final grade.

The last piece of information we need to calculate the exam grade the user needs is their goal final grade.

What you need to do: Declare one number variable named goalFinalGrade. Then, store the user’s number response to “What is your goal final grade, from 0-100?” in this variable.

Part 1.4: Calculating the exam grade.

We now have all the information we need to determine the exam grade needed by the user to achieve their goal final grade. For a moment, imagine that you know the user’s exam grade, and that their final course grade is unknown. How would you calculate their final grade in the course? Now, in this scenario, the unknown is the user’s exam grade. How do you determine this value?

What you need to do: On a piece of paper, work out a formula to compute the exam grade the user needs. Now, using the variables you created in parts 1.1-1.3, transfer this formula to your program and store the result in a number variable named examGradeNeeded. Finally, print the value of examGradeNeededNote: Only print the exam grade, do not concatenate it with a string. This will throw off the grader!

Navigate to your web browser and test with different values as input. Does the result make sense? If not, look over your formula and test it for errors in a calculator. If so, you’re ready to publish!

Part 1.4: Publish your grade calculator. With your program running in your web browser, find the green "Publish App" button. If you are not still logged into introcs.com, you will be prompted to log in, and then your app will be bundled and published to the web!

Part 1.5: Submit for grading

To submit for grading first publish your project. Then, go to My101 in the top-right right corner of this page and select "Submit" next to the assignment. From here you should see a button that allows you to submit for grading. Your work will be graded through an automated process. If you receive points off, please select the "Report" link to see which tests did not pass. You can resubmit as many times as you'd like without penalty up until the deadline. We want you to keep working toward full credit on problem sets!