Posted on

Question 1 9 points Purpose Practice with conditionals practice with variables and good program

Question 1 (9 points): Purpose: Practice with conditionals; practice with variables and good program design. Degree of Difficulty: Moderate For this problem, you will write a program that will allow a user to calculate a letter-based grade, based on a grade percentage. Here is a description of how your program should look and behave: - Initially, display the text "Grade Calculator" and "Average:" on the canvas. - When the user presses a key, show the keys pressed beside "Average:" - When the user clicks the mouse, show the calculated grade in the bottom right corner of the canvas. - If a grade is showing and the user clicks the mouse, reset the canvas, clearing both the grade and average text. Below is a table of which grade should be assigned to each average. Here are some suggestions for how to design your program, especially with regard to the Model-ViewController design pattern. - Use at least 2 global variables in your program: current keys pressed and the grade to be displayed. - Create a function that takes an average as a parameter. This function should have conditionals to determine the appropriate grade and return it. - Update the global keys pressed variable in your keyPressed() function. - Implement a conditional in your mouseClicked() function. It will either calculate an appropriate grade or reset the canvas. NOTE: You can assume that the user will always type numbers. You do not have to handle incorrect data by checking for only numbers. (Feel free to handle this as an extra challenge, but it will not be worth marks.)

Question 1 (9 points):

Purpose: Practice with conditionals; practice with variables and good program design.

Degree of Difficulty: Moderate

For this problem, you will write a program that will allow a user to calculate a letter-based grade, based on a grade percentage.

Here is a description of how your program should look and behave:

– Initially, display the text “Grade Calculator” and “Average:” on the canvas.

– When the user presses a key, show the keys pressed beside “Average:”

– When the user clicks the mouse, show the calculated grade in the bottom right corner of the canvas.

– If a grade is showing and the user clicks the mouse, reset the canvas, clearing both the grade and average text.

Below is a table of which grade should be assigned to each average.

Here are some suggestions for how to design your program, especially with regard to the Model-ViewController design pattern.

– Use at least 2 global variables in your program: current keys pressed and the grade to be displayed.

– Create a function that takes an average as a parameter. This function should have conditionals to determine the appropriate grade and return it.

– Update the global keys pressed variable in your keyPressed() function.

– Implement a conditional in your mouseClicked() function. It will either calculate an appropriate grade or reset the canvas.

NOTE: You can assume that the user will always type numbers. You do not have to handle incorrect data by checking for only numbers. (Feel free to handle this as an extra challenge, but it will not be worth marks.)


 
Solved By Verified
Study Co-Pilot All Study Co-Pilots are evaluated by Gotit Pro as an expert in their subject area.

 
Instant
Download

Student review: (3 ratings) 3 out of 3 people found this solution helpful.