Rewrite the following code using defensive programming techniques. Be sure to incorporate checks against both program crashes discussed in this section!
Set C = Sqrt(A)/B
Write C
You are given the following formula for calculating the average scores for students in a certain class. Notice that all students begin with a handicap of 20 points.
Average = (20 + Total Exam Score)/Number Exams Taken
a. Can you spot where there may be a program crash?
b. Write a program to allow the teacher to input a student’s total exam score and the number of exams that the student has taken. Then compute and display the student’s average. The variables are Average,
Total Exam Score, and Number Exams Taken.
Already registered? Login
Not Account? Sign up
Enter your email address to reset your password
Back to Login? Click here