Computer Science I for majors by James Tam

Return to the course web page

CPSC 231: Assignment 2

Due Monday October 20 at 4 PM

New Concepts to be applied for the assignment

Introduction

Time management is "..the prioritization of tasks in order to maximize personal efficiency.."1  There is only so much time among competing tasks. Many things are involved in time management but certainly one of the most important is also the most basic: how much time to allocate among tasks. Although it may be tempting to allocate all of one's time at just one aspect of life (e.g., career) there are benefits to maintaining a good work-life balance.

Assignment description

Write a time management simulation where the user can try optimizing his or her satisfaction with life as determined by academic performance (a grade point) and fun (as determined by 'fun points') The program starts by describing how the simulation works. Next the user must choose how many hours will be spent studying for exams vs. the number of hours having 'fun'. There is only a maximum of 20 hours available. Time cannot be spent 'multi-tasking' either an hour is spent studying or it is spent having fun. If the total hours entered by the user is not exactly 20 it will repeatedly re-prompt for both values.2

After receiving a valid number of hours the program will determine how much the grade point and having fun will affect overall satisfaction.

Grade point:

To keep the simulation simple there will be only one grade point. The probability of getting a higher grade point increases with additional study time (increased studying improves the odds of getting a better grade although success is never 100% guaranteed). When writing the part of your program to determine the grade point if you understand basic statistics then you can just use the data in the first column of each table (probabilities). If you need a little more help then you can use the data in the second column of each table (the percentage range). You can think of the percentage as a more complicated version of tossing a coin or rolling a die. Look at the first table for instance. If you want to simulate the 50/50 chance of either getting a GPA of zero or one by flipping a coin you could for instance assign 'heads' to equate to a GPA of one and 'tails' to a GPA of zero. Assuming that the flip of the coin is fair then there should be a 50% chance of each result. If you were trying to simulate six possible results and each result had a equal probability of occurring then you could roll a six sided die and map each face of the cube to each result. So the idea is that you somehow generate a random value and map that value to some result. Using percentage ranges you generate a random value out of possible 100 random values (think of it as rolling a 100-sided die). Instead of mapping each possible value of the die roll to a grade point (there aren't 100 possible grade points) you map a range of random values to a grade. For instance in the second table, if one spends 1 - 9 hours studying then the probability of getting a GPA of 4 is 5%. In this case a 5% probability means that out of a range of 100 values if any of the five predetermined values are generated (in this case 96 - 100) then the grade point will be a 4.  You can apply a similar approach with the other probabilities for the other grade points in the other tables.

To recap: you generate a value from 1 - 100. If the randomly generated number falls within a certain range then a certain grade point will be awarded.

Zero hours studying (not the approach to take for CPSC 231...the result is very poor)

Probability

Percentage range

Grade point

 50%

51 - 100

1

 50%

 1  - 50

0

 One to nine hours studying

Probability

Percentage range

Grade point

 5%

96 - 100

4

 5

91 - 95

3

25

66 - 90

2

25

41 - 65

1

40%

 1  - 40

0

 Ten to seventeen hours studying

Probability

Percentage range

Grade point

20%

81 - 100

4

20

61 - 80

3

20

41 - 60

2

20

21 - 40

1

20%

  1 - 20

0

Eighteen to twenty hours studying

Probability

Percentage range

Grade point

40%

61 - 100

4

25

36 - 60

3

25

11 - 35

2

 5

  6 -10

1

 5%

  1 - 5

0

Fun points:

The number of fun points is equal to the number of hours spent "having fun" divided by six (rounded up, i.e.: 1.49 rounds to 1; 1.5 rounds to 2).

Satisfaction points = grade point + fun points

Display of results

Once the satisfaction points have been determined the program will display a brief report: the number of hours spent studying and having fun, the grade point awarded and the number of satisfaction points. This report should be presented in a neat and presentable fashion.

1 Exert from www.thefreedictionary.com

2 Given the "study" hours, it is, of course, possible (and easy) to calculate the "fun" hours without prompting the user for them.  But this is NOT what is wanted.  Prompt for BOTH numbers and check to make sure they add up to 20.

Submitting your work:

  1. Assignments (the source code/'dot-py' file) must be electronically submitted according to the assignment submission requirements using D2L.
  2. As a reminder, you are not allowed to work in groups for this class. Copying the work of another student will be regarded as academic misconduct (cheating).  For additional details about what is and is not okay for this class please refer to the notes on misconduct for this course.
  3. Before you submit your assignment here is a [checklist] of items to be used in marking.

Using pre-written Python libraries

Aside from input()/print() and functions to convert types: str(), float(), int(), unless you are told otherwise, you will need to write your own code and cannot use other pre-written Python functions/methods. Functions that you can use specifically for this assignment include: round() and the methods of the 'random' library.