Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

i) A user can enter integers into the 10 cells under widget Vector X; one per cell. ii) If the user has entered 10 integers

image text in transcribed

i) A user can enter integers into the 10 cells under widget Vector X; one per cell.

ii) If the user has entered 10 integers into the 10 cells, the button initialize Vector can be pressed; and if pressed; the contents of those 10 cells are copied into a Global Vector GVEC. The order is from left to right, goes into GVEC[0] to GVEC[9].

iii) After Initialize Vector has been hit, the button sortVector() can be pressed.

iv) An integer value can be entered in widget num. After an integer value has been entered in num; the button Initialize num can be pressed.

v) Upon pressing Initialize num; the value in num is copied over into a Global Variable GNUM.

vi) Upon pressing sortVector(), the Global Vector GVEC is sorted using function sortVector.

vii) After pressing Initialize num, the button findindexofNum() can be pressed.

viii) After pressing findindexofNum(), GVEC & GNUM are passed as arguments to function indexOfNum, and the return value is displayed in widget return.

The overall intention of this GUI is to return the correct index for value in num from the sorted GVEC.

The function indexofNum is supposed to return the index of a number (int num), from the Integer Vector X.

Int indexOfNum (Integer Vector X , int num) {// X is a vector of Integers C++

// std::vector

int length = len(X) //assigns length of vector X to length

int middle = length / 2

int left = 0

int right = length 1

while(left != right) {

If(num

If(num > X[middle]) { left = middle }

middle = (left + right) / 2

}

return(left) //returns index of num in vector X

}

void sortVector(Integer Vector X)

{

int length = len(X) //assigns length of vector X to length

int temp = 0

for (int i = 0; I

for (int j = i; j

if ( X[j]

temp = X[i]

X[i] = X[j]

X[j] = temp

}

}

}

}

a.Write a Manual Test Case & Test Oracle, assuming the following steps in order---

1.Enter 10 numbers into vector x

2.Press initialize vector

3.Press sortVector()

4.Enter an integer into widget num

5.Press Initialize num

6.Press findindexofnum()

b.Steps 1 6 are not the only order that can occur. Generate an order that can

return a wrong index for num.

c) Write a Unit Test Case(s) for function indexOfNum, that exposes flaws in that

function.

Vector X Initialize Vector Initialize num num sortvectoril findindexOfNum() Vector X Initialize Vector Initialize num num sortvectoril findindexOfNum()

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

Database Systems Introduction To Databases And Data Warehouses

Authors: Nenad Jukic, Susan Vrbsky, Svetlozar Nestorov

1st Edition

1943153191, 978-1943153190

More Books

Students also viewed these Databases questions

Question

What is the Definition for Third Normal Form?

Answered: 1 week ago

Question

Provide two examples of a One-To-Many relationship.

Answered: 1 week ago