Question: How can the defensive programming be entered into a Raptor program? How does it work within a loop? How can this defensive programming be incorporated

How can the defensive programming be entered into a Raptor program? How does it work within a loop?
How can this defensive programming be incorporated within the Raptor program???
Question: How can defensive programming be added to this in case the user enters a negative number for a sc...
How can defensive programming be added to this in case the user enters a negative number for a score?
https://www.chegg.com/homework-help/Prelude-to-Programming-6th-edition-chapter-6-problem-1PC-solution-9780133750423
Expert Answer
Anonymous answered this
Was this answer helpful?
0
0
3,189 answers


// Add while Loop to defensive programming in case the user enters a negative number for a score
while(Marks
// user enters a negative number for a score
Write "Invalid input!! Marks should not be negative"
Write "Please re-enter the marks in subject:"+J
// read and store the input in variable Marks
Input Marks
End while

Set Sum Sum+ Marks End For (J) calculate the average of marks for each student Set StAvg Sum /3 I display the average marks Write "The average marks of the student"sStAvg calculate the sum of marks of all the students in I the class Set Total Total + Sum Set Sum 0 End For (I) calculate the class average Set ClsAvg-Total/ NumStudent Idisplay the class average Write "The average marks of the class is"ClsAvg Set Sum Sum+ Marks End For (J) calculate the average of marks for each student Set StAvg Sum /3 I display the average marks Write "The average marks of the student"sStAvg calculate the sum of marks of all the students in I the class Set Total Total + Sum Set Sum 0 End For (I) calculate the class average Set ClsAvg-Total/ NumStudent Idisplay the class average Write "The average marks of the class is"ClsAvg
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
