Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Exercise 5 : Static Slicing [ 1 0 % ] Consider the following Java code which reads in exam marks from array marks ( values

Exercise 5: Static Slicing [10%]
Consider the following Java code which reads in exam marks from array "marks" (values have been added to this array in preceding code) and prints the number of passes and fails, the sum of all marks, the average mark and the pass rate:7int count =0;for(int i=0;i marks.length;i++){totalMarks =0;if (marks[i]>=40)pass = pass +1 ;if (marks[i]40)fail = fail +1;count = count +1 ;totalMarks = totalMarks+marks[i];}println("Out of"+ count +","+ pass +" passed and "+ fail
" failed.");
println("The sum of all marks is "+ totalMarks);
int average = totalMarks/count;
println("The average is "+ average);
passRate =(pass/count)**100;
println("This is a pass rate of "+ passRate);
a)[6%] The program is not printing a correct average value. Construct the backward slice (at the point of the line of code that prints the average) to locate the root cause for this and correct the code.
b)[4%] Determine whether the corrections you made have any negative effects by constructing suitable forward slices.
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Systems Analysis And Synthesis Bridging Computer Science And Information Technology

Authors: Barry Dwyer

1st Edition

0128054492, 9780128054499

More Books

Students also viewed these Databases questions