Question: Generate test cases using a black box testing technique import java.util.Scanner; public class ArrayInputExample1 { public static void main(String[] args) { int n; int toFind;
Generate test cases using a black box testing technique
import java.util.Scanner;
public class ArrayInputExample1
{
public static void main(String[] args) {
int n;
int toFind;
Scanner sc=new Scanner(System.in);
System.out.print("Enter the number of elements you want to store: "); //reading the number of elements from the that we want to enter n=sc.nextInt();
Software Testing and Quality Assurance
//creates an array in the memory of length 10
int[] array = new int[10];
System.out.println("Enter the elements of the array: "); for(int i=0; i
{
//reading array elements from the user array[i]=sc.nextInt();
}
System.out.println("Enter the element to find: "); toFind = sc.nextInt();
boolean found = false;
for (int ele : array) { if (ele == toFind) {
found = true;
break; }
}
if(found)
System.out.println(toFind + " is found.");
else
System.out.println(toFind + " is not found.");
} }
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
