Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1 public class Q 1 NumberThing 2 { 3 / * * * * * * * * * * * * * * *

1 public class Q1NumberThing
2{
3/*************************************************************
4* Sums all numbers in the list greater than y.*
5* Divides the total by the magnitude of the list. *
6* If anything is invalid, -1.0 is returned instead. *
7**************************************************************/
8 public static double numberThing(List intList, int y)
9{
10 if (intList == null)
11 return -1.0;
12 else
13{
14 double sum =0.0;
15 for(Integer nextInt: intList)
16{
17 if(nextInt > y)
18 sum = sum +(double)nextInt;
19}
20
21 if(sum ==0)
22 return -1.0;
23
24 double result = sum /(double)intList.size();
25 return result;
26}
27}
28
29 public static void main(String[] args)
30{
31 double result = numberThing(/*parameters go here*/);
32 System.out.println(result);
33}
34}
Explain what is wrong with the given code. Describe the fault precisely by proposing a modification
If possible, give a test case that does not execute the fault. If not, briefly explain
why not.
If possible, give a test case that executes the fault, but does not result in an error
state. If not, briefly explain why not.
If possible give a test case that results in an error, but not a failure. If not, briefly
explain why not.
e) In the given code, describe the first error state. Be sure to describe the complete
state.

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_2

Step: 3

blur-text-image_3

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

OCA Oracle Database SQL Exam Guide Exam 1Z0-071

Authors: Steve O'Hearn

1st Edition

1259585492, 978-1259585494

More Books

Students also viewed these Databases questions

Question

Identify traditional external recruitment methods.

Answered: 1 week ago

Question

Describe alternatives to recruitment.

Answered: 1 week ago